Example #1
0
File: main.c Project: bartman/wmii
static void
scan_wins(void) {
	int i;
	uint num;
	XWindow *wins;
	XWindowAttributes wa;
	XWindow d1, d2;

	if(XQueryTree(display, scr.root.xid, &d1, &d2, &wins, &num)) {
		for(i = 0; i < num; i++) {
			if(!XGetWindowAttributes(display, wins[i], &wa))
				continue;
			/* Skip transients. */
			if(wa.override_redirect || XGetTransientForHint(display, wins[i], &d1))
				continue;
			if(wa.map_state == IsViewable)
				client_create(wins[i], &wa);
		}
		/* Manage transients. */
		for(i = 0; i < num; i++) {
			if(!XGetWindowAttributes(display, wins[i], &wa))
				continue;
			if((XGetTransientForHint(display, wins[i], &d1))
			&& (wa.map_state == IsViewable))
				client_create(wins[i], &wa);
		}
	}
	if(wins)
		XFree(wins);
}
Example #2
0
File: dawm.c Project: dstenb/dawm
bool
manageable_window(Window win, XWindowAttributes *attr, bool trans)
{
	Window dummy;

	if (!XGetWindowAttributes(dpy, win, attr))
		return false;
	if (trans && !XGetTransientForHint(dpy, win, &dummy))
		return false;
	if (!trans && (attr->override_redirect ||
				XGetTransientForHint(dpy, win, &dummy)))
		return false;
	return (attr->map_state == IsViewable ||
			get_state(win) == IconicState);
}
Example #3
0
Client * client_new(Window win)
{
    Client *c;
    long supplied;
    Atom win_type;

    XGetWindowAttributes(display, win, &attr);

    if (attr.override_redirect) return NULL;
    if (c = client_find(win)) return NULL;

    c = malloc(sizeof *c);
    c->next = head;
    head = c;

    c->win = win;

    c->name = ewmh_get_text(c, WM_NAME);
    c->geom.x = attr.x;
    c->geom.y = 16;
    c->geom.w = attr.width;
    c->geom.h = attr.height;

    XGetWMNormalHints(display, c->win, &c->size, &supplied);
    XGetTransientForHint(display, c->win, &c->trans);

    return c;
}
Example #4
0
File: main.c Project: xiaq/hlwm
// scan for windows and add them to the list of managed clients
// from dwm.c
void scan(void) {
    unsigned int num;
    Window d1, d2, *cl, *wins = NULL;
    unsigned long cl_count;
    XWindowAttributes wa;

    ewmh_get_original_client_list(&cl, &cl_count);
    if (XQueryTree(g_display, g_root, &d1, &d2, &wins, &num)) {
        for (int i = 0; i < num; i++) {
            if(!XGetWindowAttributes(g_display, wins[i], &wa)
            || wa.override_redirect || XGetTransientForHint(g_display, wins[i], &d1))
                continue;
            // only manage mapped windows.. no strange wins like:
            //      luakit/dbus/(ncurses-)vim
            // but manage it if it was in the ewmh property _NET_CLIENT_LIST by
            // the previous window manager
            // TODO: what would dwm do?
            if (is_window_mapped(g_display, wins[i])
                || 0 <= array_find(cl, cl_count, sizeof(Window), wins+i)) {
                manage_client(wins[i]);
                XMapWindow(g_display, wins[i]);
            }
        }
        if(wins)
            XFree(wins);
    }
}
Example #5
0
void rootwin_manage_initial_windows(WRootWin *rootwin)
{
    Window *wins=rootwin->tmpwins;
    Window tfor=None;
    int i, nwins=rootwin->tmpnwins;

    rootwin->tmpwins=NULL;
    rootwin->tmpnwins=0;
    
    for(i=0; i<nwins; i++){
        if(XWINDOW_REGION_OF(wins[i])!=NULL)
            wins[i]=None;
        if(wins[i]==None)
            continue;
        if(XGetTransientForHint(ioncore_g.dpy, wins[i], &tfor))
            continue;
        ioncore_manage_clientwin(wins[i], FALSE);
        wins[i]=None;
    }

    for(i=0; i<nwins; i++){
        if(wins[i]==None)
            continue;
        ioncore_manage_clientwin(wins[i], FALSE);
    }
    
    XFree((void*)wins);
}
Example #6
0
BZclient::BZclient( Display* dpy, Window w ) {

    XWindowAttributes attr;
    long dummy ;
    XWMHints *hints ;

    XGrabServer(dpy);
    XGetTransientForHint(dpy, w, &transient);
    XFetchName(dpy, w, &name);
    XGetWindowAttributes(dpy, w, &attr);

    window = w ;
    ignore_unmap = 0 ;
    x = attr.x ;
    y = attr.y ;
    width = attr.width ;
    height = attr.height ;
    cmap = attr.colormap ;
    size = XAllocSizeHints() ;
    
    XGetWMNormalHints(dpy, window, size, &dummy);







    XSync(dpy, False);
    XUngrabServer(dpy);


}
Example #7
0
void map_notify_handler(XEvent local_event, Display* display, ScreenInfos infos){
	printf("----------Map Notify\n");
	XWindowAttributes win_attr;
	char *child_name;
	XGetWindowAttributes(display, local_event.xmap.window, &win_attr);
	XFetchName(display, local_event.xmap.window, &child_name);
	printf("\tAttributes: W: %d - H: %d - Name: %s - ID %lu\n", win_attr.width, win_attr.height, child_name, local_event.xmap.window);
	Window trans = None;	
	XGetTransientForHint(display, local_event.xmap.window, &trans);	
	printf("\tIs transient: %ld\n", trans);
	if(child_name!=NULL){
	  if(strcmp(child_name, "Parent") && local_event.xmap.override_redirect == False){
		Window new_win = draw_window_with_name(display, RootWindow(display, infos.screen_num), "Parent", infos.screen_num, 
						   win_attr.x, win_attr.y, win_attr.width, win_attr.height+DECORATION_HEIGHT, 0, 
						   BlackPixel(display, infos.screen_num));
		XMapWindow(display, new_win);
		XReparentWindow(display,local_event.xmap.window, new_win,0, DECORATION_HEIGHT);
		set_window_item(local_event.xmap.window, new_win);
		XSelectInput(display, local_event.xmap.window, StructureNotifyMask);
		printf("\tParent window id: %lu\n", new_win);
		put_text(display, new_win, child_name, "9x15", 10, 10, BlackPixel(display,infos.screen_num), WhitePixel(display, infos.screen_num));
	  } /*else {
		  XWindowAttributes attributes;
		  Status status = XGetWindowAttributes(display, local_event.xmap.window, &attributes);
		  printf("\tStatus: %d\n", attributes.map_state);
		  printf("\tOverride redirect: %d\n", attributes.override_redirect);
		  //XMapWindow(display, trans);
		  XFetchName(display, trans, &child_name);
		  printf("\tChild name: %s\n", child_name);
		  //XRaiseWindow(local_event.xmap.display, local_event.xmap.window);
		  //XCirculateSubwindows(local_event.xmap.display, local_event.xmap.window, RaiseLowest);
	  }*/
	}
	XFree(child_name);
}
Example #8
0
void TaskManager::windowAdded(WId w )
{
  NETWinInfo info(qt_xdisplay(),  w, qt_xrootwin(),
                  NET::WMWindowType | NET::WMPid | NET::WMState );
  #ifdef KDE_3_2
  NET::WindowType windowType = info.windowType(NET_ALL_TYPES_MASK);
  #else
  NET::WindowType windowType = info.windowType();
  #endif
  // ignore NET::Tool and other special window types
  if (windowType != NET::Normal && windowType != NET::Override
      && windowType != NET::Unknown && windowType != NET::Dialog)
    return;
  // ignore windows that want to be ignored by the taskbar
  if ((info.state() & NET::SkipTaskbar) != 0)
  {
      _skiptaskbar_windows.push_front( w ); // remember them though
    return;
  }

  Window transient_for_tmp;
  if (XGetTransientForHint(qt_xdisplay(), (Window) w, &transient_for_tmp))
  {
    WId transient_for = (WId) transient_for_tmp;

    // check if it's transient for a skiptaskbar window
    if (_skiptaskbar_windows.contains(transient_for))
      return;

    // lets see if this is a transient for an existing task
    if (transient_for != qt_xrootwin() && transient_for != 0 )
    {
      Task* t = findTask(transient_for);
      if (t)
      {
        if (t->window() != w)
        {
          t->addTransient(w);
          // kdDebug() << "TM: Transient " << w << " added for Task: " << t->window() << endl;
        }
        return;
      }
    }
  }
  Task* t = new Task(w, this);
  _tasks.append(t);

  // kdDebug() << "TM: Task added for WId: " << w << endl;
  emit taskAdded(t);
}
Example #9
0
// scan for windows and add them to the list of managed clients
void scan(void) {
    unsigned int i, num;
    Window d1, d2, *wins = NULL;
    XWindowAttributes wa;

    if(XQueryTree(gDisplay, gRoot, &d1, &d2, &wins, &num)) {
        for(i = 0; i < num; i++) {
            if(!XGetWindowAttributes(gDisplay, wins[i], &wa)
            || wa.override_redirect || XGetTransientForHint(gDisplay, wins[i], &d1))
                continue;
            if (wa.map_state == IsViewable)
                manage_client(wins[i]);
        }
        for(i = 0; i < num; i++){ // now the transients
           if(!XGetWindowAttributes(gDisplay, wins[i], &wa))
              continue;
           if(XGetTransientForHint(gDisplay, wins[i], &d1)
              && (wa.map_state == IsViewable))
              manage_client(wins[i]);
        }
        if(wins) XFree(wins);
    }
}
Example #10
0
File: event.c Project: n4cht/kwm
/** PropertyNotify handle event
 * \param ev XPropertyEvent pointer
*/
static void
propertynotify(XPropertyEvent *ev)
{
     Client *c;
     Systray *s;
     Window trans;
     XWMHints *h;

     if(ev->state == PropertyDelete)
          return;

     if((s = systray_find(ev->window)))
     {
          systray_state(s);
          systray_update();
     }

     if((c = client_gb_win(ev->window)))
     {
          switch(ev->atom)
          {
          case XA_WM_TRANSIENT_FOR:
               XGetTransientForHint(dpy, c->win, &trans);
               if((c->flags & TileFlag || c->flags & MaxFlag))
                    if(((c->flags & HintFlag && (client_gb_win(trans) != NULL)))
                              || (!(c->flags & HintFlag && (client_gb_win(trans) != NULL))))
                         arrange(c->screen, True);
               break;
          case XA_WM_NORMAL_HINTS:
               client_size_hints(c);
               break;
          case XA_WM_HINTS:
               if((h = XGetWMHints(dpy, c->win)) && (h->flags & XUrgencyHint) && c != sel)
               {
                    client_urgent(c, True);
                    XFree(h);
               }
               break;
          case XA_WM_NAME:
               client_get_name(c);
               break;
          default:
               if(ev->atom == net_atom[net_wm_name])
                    client_get_name(c);
               break;
          }
     }

     return;
}
Example #11
0
/**
 * Get the window this window is transient for, if any.
 * @param win The window to check
 * @return The window ID of the top-level window, or 0 if the property does not exist.
 */
EAPI Ecore_X_Window
ecore_x_icccm_transient_for_get(Ecore_X_Window win)
{
   Window forwin;
   Eina_Bool success;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   success = XGetTransientForHint(_ecore_x_disp, win, &forwin);
   if (_ecore_xlib_sync) ecore_x_sync();
   if (success)
     return (Ecore_X_Window)forwin;
   else
     return 0;
}
Example #12
0
void
manage(Window w, XWindowAttributes *wa) {
    Client *c, *t;
    Window trans;

    c = emallocz(sizeof(Client));
    c->win = w;
    c->x = wa->x;
    c->y = wa->y;
    c->w = wa->width;
    c->h = wa->height;
    if(c->w == sw && c->h == sh) {
        c->border = 0;
        c->x = sx;
        c->y = sy;
    }
    else {
        c->border = BORDERPX;
        if(c->x + c->w + 2 * c->border > sx + sw)
            c->x = sx + sw - c->w - 2 * c->border;
        if(c->y + c->h + 2 * c->border > sy + sh)
            c->y = sy + sh - c->h - 2 * c->border;
        if(c->x < sx)
            c->x = sx;
        if(c->y < sy)
            c->y = sy;
    }
    updatesizehints(c);
    XSelectInput(dpy, c->win,
        StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
    XGetTransientForHint(dpy, c->win, &trans);
    XSetWindowBorder(dpy, c->win, normcol);
    updatetitle(c);
    if((t = getclient(trans)))
        c->view = t->view;
    else
        c->view = view;
    if(clients)
        clients->prev = c;
    c->next = clients;
    c->snext = stack;
    stack = clients = c;
    XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
    XMapWindow(dpy, c->win);
    setclientstate(c, NormalState);
    if(c->view == view)
        focus(c);
    arrange();
}
Example #13
0
/**
 * @brief this one gets the active application window.
 */
Window XfitMan::getActiveAppWindow() const
{
    Window window = getActiveWindow();
    if (window == 0)
        return 0;

    if (acceptWindow(window))
        return window;

    Window transFor = None;
    if (XGetTransientForHint(QX11Info::display(), window, &transFor))
        return transFor;

    return 0;
}
Example #14
0
gboolean window_is_hidden(Window win)
{
	Window window;
	int count;

	Atom *at = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count);
	for (int i = 0; i < count; i++) {
		if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
			XFree(at);
			return TRUE;
		}
		// do not add transient_for windows if the transient window is already in the taskbar
		window = win;
		while (XGetTransientForHint(server.display, window, &window)) {
			if (get_task_buttons(window)) {
				XFree(at);
				return TRUE;
			}
		}
	}
	XFree(at);

	at = server_get_property(win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count);
	for (int i = 0; i < count; i++) {
		if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP ||
			at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU ||
			at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) {
			XFree(at);
			return TRUE;
		}
	}
	XFree(at);

	for (int i = 0; i < num_panels; i++) {
		if (panels[i].main_win == win) {
			return TRUE;
		}
	}

	// specification
	// Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set
	// MUST be taken as top-level window.
	return FALSE;
}
Example #15
0
void Client::getTransient()
{
    Window t = None;

    if (XGetTransientForHint(display(), m_window, &t) != 0) {

	if (windowManager()->windowToClient(t) == this) {
	    fprintf(stderr,
		    "wm2: warning: client \"%s\" thinks it's a transient "
		    "for\nitself -- ignoring WM_TRANSIENT_FOR property...\n",
		    m_label ? m_label : "(no name)");
	    m_transient = None;
	} else {		
	    m_transient = t;
	}
    } else {
	m_transient = None;
    }
}
Example #16
0
void active_task()
{
	if (task_active) {
		set_task_state(task_active, window_is_iconified(task_active->win) ? TASK_ICONIFIED : TASK_NORMAL);
		task_active = 0;
	}

	Window w1 = window_get_active();
	//printf("Change active task %ld\n", w1);

	if (w1) {
		if (!task_get_tasks(w1)) {
			Window w2;
			while (XGetTransientForHint(server.dsp, w1, &w2))
				w1 = w2;
		}
		set_task_state((task_active = task_get_task(w1)), TASK_ACTIVE);
	}
}
Example #17
0
/**
 * @brief rejects a window from beeing listed
 */
bool XfitMan::acceptWindow(Window window) const
{
    {
        AtomList types = getWindowType(window);
        AtomList ignoreList;
        ignoreList  << atom("_NET_WM_WINDOW_TYPE_DESKTOP")
                    << atom("_NET_WM_WINDOW_TYPE_DOCK")
                    << atom("_NET_WM_WINDOW_TYPE_SPLASH")
                    << atom("_NET_WM_WINDOW_TYPE_TOOLBAR")
                    << atom("_NET_WM_WINDOW_TYPE_MENU")
                    // for qlipper - using qpopup as a main window
                    << atom("_NET_WM_WINDOW_TYPE_POPUP_MENU");
        // issue #284: qmmp its not registered in window list panel
        // qmmp has _KDE_NET_WM_WINDOW_TYPE_OVERRIDE in its
        // _NET_WM_WINDOW_TYPE(ATOM) = _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL
        // Let's expect that _KDE_NET_WM_WINDOW_TYPE_OVERRIDE can be set for
        // regular windows too. If it should be hidden we should expect
        // one of atoms listed above.
//                    << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");

        foreach (Atom i, ignoreList)
        {
            if (types.contains(i))
                return false;
        }

        WindowState state = getWindowState(window);
        if (state.SkipTaskBar)  return false;
    }

    Window transFor = None;
    // WM_TRANSIENT_FOR hint not set - normal window
    if (!XGetTransientForHint(QX11Info::display(), window, &transFor))
        return true;

    if (transFor == 0)      return true;
    if (transFor == window) return true;
    if (transFor == root)   return true;

     AtomList transForTypes = getWindowType(transFor);
     return !transForTypes.contains(atom("_NET_WM_WINDOW_TYPE_NORMAL"));
}
Example #18
0
File: main.c Project: csimons/cswm
static void
scan(void) {
    unsigned int i, num;
    Window *wins, d1, d2;
    XWindowAttributes wa;

    wins = NULL;
    if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
        for(i = 0; i < num; i++) {
            if(!XGetWindowAttributes(dpy, wins[i], &wa))
                continue;
            if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
                continue;
            if(wa.map_state == IsViewable)
                manage(wins[i], &wa);
        }
    }
    if(wins)
        XFree(wins);
}
Example #19
0
File: window.c Project: asqz/tint2
int window_is_hidden (Window win)
{
	Window window;
	Atom *at;
	int count, i;

	at = server_get_property (win, server.atom._NET_WM_STATE, XA_ATOM, &count);
	for (i = 0; i < count; i++) {
		if (at[i] == server.atom._NET_WM_STATE_SKIP_TASKBAR) {
			XFree(at);
			return 1;
		}
		// do not add transient_for windows if the transient window is already in the taskbar
		if ( XGetTransientForHint(server.dsp, win, &window) && task_get_tasks(window) ) {
			XFree(at);
			return 1;
		}
	}
	XFree(at);

	at = server_get_property (win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, &count);
	for (i = 0; i < count; i++) {
		if (at[i] == server.atom._NET_WM_WINDOW_TYPE_DOCK || at[i] == server.atom._NET_WM_WINDOW_TYPE_DESKTOP || at[i] == server.atom._NET_WM_WINDOW_TYPE_TOOLBAR || at[i] == server.atom._NET_WM_WINDOW_TYPE_MENU || at[i] == server.atom._NET_WM_WINDOW_TYPE_SPLASH) {
			XFree(at);
			return 1;
		}
	}
	XFree(at);

	for (i=0 ; i < nb_panel ; i++) {
		if (panel1[i].main_win == win) {
			return 1;
		}
	}

	// specification
	// Windows with neither _NET_WM_WINDOW_TYPE nor WM_TRANSIENT_FOR set
	// MUST be taken as top-level window.
	return 0;
}
Example #20
0
static void
propertynotify(XEvent *e) {
	Client *c;
	Window trans;
	XPropertyEvent *ev = &e->xproperty;

	if(ev->state == PropertyDelete)
		return; /* ignore */
	if((c = getclient(ev->window))) {
		switch (ev->atom) {
			default: break;
			case XA_WM_TRANSIENT_FOR:
				XGetTransientForHint(dpy, c->win, &trans);
				if(!c->isfloat && (c->isfloat = (trans != 0)))
					arrange();
				break;
			case XA_WM_NORMAL_HINTS:
				updatesizehints(c);
				break;
		}
	}
}
Example #21
0
void HandlePropertyNotify()
{
  XTextProperty text_prop;
  Boolean       OnThisPage    =  False;

  DBUG("HandlePropertyNotify","Routine Entered");

  if ((!Tmp_win)||
      (XGetGeometry(dpy, Tmp_win->w, &JunkRoot, &JunkX, &JunkY,
		    &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0))
    return;

  /*
      Make sure at least part of window is on this page
      before giving it focus...
  */
  if ( (Tmp_win->Desk == Scr.CurrentDesk) &&
       ( ((Tmp_win->frame_x + Tmp_win->frame_width) >= 0 &&
          Tmp_win->frame_x < Scr.MyDisplayWidth) &&
         ((Tmp_win->frame_y + Tmp_win->frame_height) >= 0 &&
          Tmp_win->frame_y < Scr.MyDisplayHeight)
       )
     )
    {
      OnThisPage  =  True;
    }

  switch (Event.xproperty.atom)
    {
    case XA_WM_TRANSIENT_FOR:
      {
        if(XGetTransientForHint(dpy, Tmp_win->w, &Tmp_win->transientfor))
        {
           Tmp_win->flags |= TRANSIENT;
           RaiseWindow(Tmp_win);
        }
        else
        {
           Tmp_win->flags &= ~TRANSIENT;
        }
      }
      break;

    case XA_WM_NAME:
      if (!XGetWMName(dpy, Tmp_win->w, &text_prop))
	return;

      free_window_names (Tmp_win, True, False);

      Tmp_win->name = (char *)text_prop.value;
      if (Tmp_win->name && strlen(Tmp_win->name) > 200)
	/* limit to prevent hanging X server */
	Tmp_win->name[200] = 0;

      if (Tmp_win->name == NULL)
        Tmp_win->name = NoName;
      BroadcastName(M_WINDOW_NAME,Tmp_win->w,Tmp_win->frame,
		    (unsigned long)Tmp_win,Tmp_win->name);

      /* fix the name in the title bar */
      if(!(Tmp_win->flags & ICONIFIED))
	SetTitleBar(Tmp_win,(Scr.Hilite==Tmp_win),True);

      /*
       * if the icon name is NoName, set the name of the icon to be
       * the same as the window
       */
      if (Tmp_win->icon_name == NoName)
	{
	  Tmp_win->icon_name = Tmp_win->name;
	  BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame,
			(unsigned long)Tmp_win,Tmp_win->icon_name);
	  RedoIconName(Tmp_win);
	}
      break;

    case XA_WM_ICON_NAME:
      if (!XGetWMIconName (dpy, Tmp_win->w, &text_prop))
	return;
      free_window_names (Tmp_win, False, True);
      Tmp_win->icon_name = (char *) text_prop.value;
      if (Tmp_win->icon_name && strlen(Tmp_win->icon_name) > 200)
	/* limit to prevent hanging X server */
	Tmp_win->icon_name[200] = 0;
      if (Tmp_win->icon_name == NULL)
        Tmp_win->icon_name = NoName;
      BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame,
		    (unsigned long)Tmp_win,Tmp_win->icon_name);
      RedoIconName(Tmp_win);
      break;

    case XA_WM_HINTS:
      if (Tmp_win->wmhints)
	XFree ((char *) Tmp_win->wmhints);
      Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window);

      if(Tmp_win->wmhints == NULL)
	return;

      if((Tmp_win->wmhints->flags & IconPixmapHint)||
	 (Tmp_win->wmhints->flags & IconWindowHint))
	if(Tmp_win->icon_bitmap_file == Scr.DefaultIcon)
	  Tmp_win->icon_bitmap_file = (char *)0;

      if((Tmp_win->wmhints->flags & IconPixmapHint)||
         (Tmp_win->wmhints->flags & IconWindowHint))
	{
	  if (!(Tmp_win->flags & SUPPRESSICON))
	    {
              if (Tmp_win->icon_w)
                XDestroyWindow(dpy,Tmp_win->icon_w);
	      XDeleteContext(dpy, Tmp_win->icon_w, FvwmContext);
	      if(Tmp_win->flags & ICON_OURS)
		{
		  if(Tmp_win->icon_pixmap_w != None)
		    {
		      XDestroyWindow(dpy,Tmp_win->icon_pixmap_w);
		      XDeleteContext(dpy, Tmp_win->icon_pixmap_w, FvwmContext);
		    }
		}
	      else
		XUnmapWindow(dpy,Tmp_win->icon_pixmap_w);
	    }
          Tmp_win->icon_w = None;
          Tmp_win->icon_pixmap_w = None;
	  Tmp_win->iconPixmap = (Window)NULL;
	  if(Tmp_win->flags & ICONIFIED)
	    {
	      Tmp_win->flags &= ~ICONIFIED;
	      Tmp_win->flags &= ~ICON_UNMAPPED;
	      CreateIconWindow(Tmp_win,
			       Tmp_win->icon_x_loc,Tmp_win->icon_y_loc);
	      BroadcastPacket(M_ICONIFY, 7,
                              Tmp_win->w, Tmp_win->frame,
                              (unsigned long)Tmp_win,
                              Tmp_win->icon_x_loc, Tmp_win->icon_y_loc,
                              Tmp_win->icon_w_width, Tmp_win->icon_w_height);
	      BroadcastConfig(M_CONFIGURE_WINDOW, Tmp_win);

	      if (!(Tmp_win->flags & SUPPRESSICON))
		{
		  LowerWindow(Tmp_win);
		  AutoPlace(Tmp_win);
		  if(Tmp_win->Desk == Scr.CurrentDesk)
		    {
                      if(Tmp_win->icon_w)
                        XMapWindow(dpy, Tmp_win->icon_w);
		      if(Tmp_win->icon_pixmap_w != None)
			XMapWindow(dpy, Tmp_win->icon_pixmap_w);
		    }
		}
	      Tmp_win->flags |= ICONIFIED;
	      DrawIconWindow(Tmp_win);
	    }
	}
      break;

    case XA_WM_NORMAL_HINTS:
      GetWindowSizeHints (Tmp_win);
#if 0
      /*
      ** ckh - not sure why this next stuff was here, but fvwm 1.xx
      ** didn't do this, and it seems to cause a bug when changing
      ** fonts in XTerm
      */
      {
	int new_width, new_height;
	new_width = Tmp_win->frame_width;
	new_height = Tmp_win->frame_height;
	ConstrainSize(Tmp_win, &new_width, &new_height, False, 0, 0);
	if((new_width != Tmp_win->frame_width)||
	   (new_height != Tmp_win->frame_height))
	  SetupFrame(Tmp_win,Tmp_win->frame_x, Tmp_win->frame_y,
		     new_width,new_height,False);
      }
#endif /* 0 */
      BroadcastConfig(M_CONFIGURE_WINDOW,Tmp_win);
      break;

    default:
      if(Event.xproperty.atom == _XA_WM_PROTOCOLS)
	FetchWmProtocols (Tmp_win);
      else if (Event.xproperty.atom == _XA_WM_COLORMAP_WINDOWS)
	{
	  FetchWmColormapWindows (Tmp_win);	/* frees old data */
	  ReInstallActiveColormap();
	}
      else if(Event.xproperty.atom == _XA_WM_STATE)
	{
	  if((Tmp_win != NULL)&&(Tmp_win->flags & ClickToFocus)
	     &&(Tmp_win == Scr.Focus))
	    {
              if (OnThisPage)
              {
	        Scr.Focus = NULL;
	        SetFocus(Tmp_win->w,Tmp_win,0);
              }
	    }
	}
      break;
    }
}
Example #22
0
/***********************************************************************
 * Event Handler to reparent client window under plugin window 
 ***********************************************************************/
/* static */ void
SubstructureRedirectHandler (
    Widget widget, 
    XtPointer client_data, 
    XEvent* event, 
    Boolean* cont)
{
    windowrec* new_list;
    PluginInstance* This = (PluginInstance*) client_data;

#ifdef PLUGIN_TRACE
    fprintf (stderr, "%s\n", "SubstructureRedirectHandler");
    fprintf (stderr, "This: 0x%x\n", This);
#endif

    switch (event->type) {
    case ConfigureRequest:
	{
	    XWindowChanges config;
	    config.x = event->xconfigurerequest.x;
	    config.y = event->xconfigurerequest.y;
	    config.width = event->xconfigurerequest.width;
	    config.height = event->xconfigurerequest.height;
	    config.border_width = event->xconfigurerequest.border_width;
	    config.sibling = event->xconfigurerequest.above;
	    config.stack_mode = event->xconfigurerequest.detail;
#if 0
	    fprintf (stderr, "configuring at %dx%d+%d+%d\n", 
		     config.width, config.height, config.x, config.y);
#endif
	    XConfigureWindow (RxGlobal.dpy,
			      event->xconfigurerequest.window,
			      event->xconfigurerequest.value_mask,
			      &config);
	}
	break;

    case MapRequest:

	RxpSetStatusWidget(This, RUNNING);

	{
	    Window for_win;
	    int i;

	    if (XGetTransientForHint (RxGlobal.dpy, event->xmaprequest.window,
				      &for_win)) {
		for (i = 0; i < This->nclient_windows; i++)
		    if (for_win == This->client_windows[i].win)
			XMapWindow (RxGlobal.dpy, event->xmaprequest.window);
		return;
	    }
	}
	new_list = (windowrec*) 
	    NPN_MemAlloc (sizeof (windowrec) * (This->nclient_windows + 1));
	if (new_list) {
	    Position x, y;
	    Dimension width, height;
	    Dimension border_width;
	    Colormap cmap;
	    int n;
	    Atom* wm_proto;
	    windowrec* wp;
	    Window destwin = XtWindow (This->plugin_widget);

	    This->nclient_windows++;
	    if (This->nclient_windows > 1)
		memcpy ((void*) new_list, (void*) This->client_windows,
			(This->nclient_windows - 1) * sizeof (windowrec));
	    if (This->client_windows)
		NPN_MemFree (This->client_windows);
	    This->client_windows = new_list;

	    x = y = 0;
	    width = height = border_width = 0;
	    GetWindowGeometry (RxGlobal.dpy, event->xmaprequest.window, 
			       &x, &y, &width, &height, &border_width, &cmap);

	    wp = &This->client_windows[This->nclient_windows - 1];
	    wp->win = event->xmaprequest.window;
	    wp->x = x; wp->y = y;
	    wp->width = width; wp->height = height;
	    wp->border_width = border_width;
	    wp->flags = RxpMapped;
	    wp->colormap = cmap;

	    if (XGetWMProtocols (RxGlobal.dpy, wp->win, &wm_proto, &n)) {
		int i;
		Atom* ap;

		for (i = 0, ap = wm_proto; i < n; i++, ap++) {
		    if (*ap == RxGlobal.wm_delete_window)
			wp->flags |= RxpWmDelWin;
		}
		if (wm_proto) XFree ((char*) wm_proto);
	    }

	    XSelectInput(RxGlobal.dpy, wp->win,
			 EnterWindowMask | LeaveWindowMask);
	    XtRegisterDrawable (RxGlobal.dpy, wp->win, This->plugin_widget);
	    XReparentWindow (RxGlobal.dpy, wp->win, destwin, wp->x, wp->y);
	    XMapWindow (RxGlobal.dpy, wp->win);
	}
	break;
    }
}
Example #23
0
int
Rwm_take_windows(struct R_app *app)
{
    struct R_wm *wm;
    struct R_window *root;
    int screen;
    int x;
    int y;
    int w;
    int h;
    unsigned int nchildren;
    unsigned int ui;
    Screen *screenptr;
    Window *children;
    Window rootwin;
    Window win;
    struct R_window *window;
    struct R_window *frame;
    XWindowAttributes attr;

    wm = app->client;
    root = app->window;
    screen = app->screen;
    screenptr = ScreenOfDisplay(app->display,
                                screen);
    w = root->w;
    h = root->h;
    rootwin = app->winid;
    if (XQueryTree(app->display,
                   rootwin,
                   &rootwin,
                   &win,
                   &children,
                   &nchildren)) {
#if (RWMLAZYSYNC)
        _ignbadwindow = 1;
        _ignbadmatch = 1;
#endif
        if (nchildren) {
            ui = 0;
#if (!RWMLAZYSYNC)
            _ignbadwindow = 1;
            _ignbadmatch = 1;
#endif
            while (ui < nchildren) {
                win = children[ui];
                memset(&attr, 0, sizeof(attr));
                XGetWindowAttributes(app->display,
                                     win,
                                     &attr);
                x = attr.x;
                if (!attr.override_redirect) {
#if (RWM_EXEC_RL)
                    y = max(attr.y, RL_BUTTON_HEIGHT + RWM_MENU_ITEM_HEIGHT);
#else
                    y = max(attr.y, RWM_MENU_ITEM_HEIGHT);
#endif
                }
                w = attr.width;
                h = attr.height;
                window = R_find_window(win);
                if (!window) {
                    window = R_alloc_window();
                    if (window) {
                        window->app = app;
                        window->id = win;
                        window->x = x;
                        window->y = y;
                        window->w = w;
                        window->h = h;
                        window->border = attr.border_width;
                        if (!attr.override_redirect) {
                            R_add_save_window(window);
                            window->sysflags |= R_WINDOW_STATIC_IMAGES_FLAG;
                            if (attr.save_under) {
                                window->sysflags |= R_WINDOW_SAVE_UNDER_FLAG;
                            }
                            if (attr.backing_store) {
                                window->sysflags |= R_WINDOW_BACK_STORE_FLAG;
                            }
                            XGetTransientForHint(app->display,
                                                 window->id,
                                                 &win);
                            if (win) {
                                window->typeflags = R_WINDOW_TRANSIENT_FLAG;
                            } else {
                                window->typeflags = R_WINDOW_TOPLEVEL_FLAG;
                            }
                            XSetWindowBorderWidth(window->app->display,
                                                  window->id,
                                                  window->border);
                            frame = Rwm_frame_window(window);
                            Rwm_reparent_window(frame,
                                                wm->desktop,
                                                window->x,
                                                window->y);
                            R_map_window_raised(frame);
                            Rwm_init_frame_events(frame);
                            Rwm_get_title(window);
                            Rwm_draw_text(frame->chain);
                            R_add_window(window);
                            Rwm_init_client_events(window);
                        } else {
                            window->typeflags = R_WINDOW_OVERRIDE_FLAG;
                            Rwm_reparent_window(window,
//                                                wm->desktop,
                                                app->window,
                                                window->x,
                                                window->y);
                            R_add_window(window);
                            R_map_window_raised(window);
                            R_set_window_events(window,
                                                NoEventMask);
                            R_free_window(window);
                        }
                    }
#if (!RWMLAZYSYNC)
                    XSync(app->display,
                          False);
#endif
                }
                ui++;
            }
#if (RWMLAZYSYNC)
            XSync(app->display,
                  False);
#endif
            _ignbadwindow = 0;
            _ignbadmatch = 0;
            XFree(children);
        }
    }

    return TRUE;
}
Example #24
0
/**
@brief   Determines the frame type and sets the appropriate stacking mode.
@return  void
**/
static void
get_frame_type_and_mode(Display *display, struct Frame *frame, struct Atoms *atoms, struct Themes *themes) {
  unsigned char *contents = NULL;
  Atom return_type;
  int return_format;
  unsigned long items;
  unsigned long bytes;

  XGetTransientForHint(display, frame->framed_window, &frame->transient);

  XGetWindowProperty(display, frame->framed_window, atoms->wm_window_type, 0, 1 //long long_length?
  , False, AnyPropertyType, &return_type, &return_format,  &items, &bytes, &contents);

  frame->type = unknown;
  frame->mode = floating;

  if(return_type == XA_ATOM  && contents != NULL) {
    Atom *window_type = (Atom*)contents;
    #ifdef SHOW_PROPERTIES
    printf("Number of atoms %lu\n", items);
    #endif
    for(unsigned int i =0; i < items; i++) {
    //these are fairly mutually exclusive so be suprised if there are others
      if(window_type[i] == atoms->wm_window_type_desktop) {
        #ifdef SHOW_PROPERTIES
        printf("mode/type: desktop\n");
        #endif
        frame->mode = desktop;
        //frame->mode = floating;
        //There are no desktop windows - desktops are normal "programs"
        if(themes->window_type[program]) frame->type = program;
      }
      else if(window_type[i] == atoms->wm_window_type_normal) {
        #ifdef SHOW_PROPERTIES
        printf("type: normal/definately unknown\n");
        #endif
        frame->mode = tiling;
        frame->type = unknown;
      }
      else if(window_type[i] == atoms->wm_window_type_dock) {
        #ifdef SHOW_PROPERTIES
        printf("type: dock\n");
        #endif
        frame->mode = tiling;
        if(themes->window_type[panel]) frame->theme_type = panel;
        frame->type = panel;
        frame->sticky = True;
      }
      else if(window_type[i] == atoms->wm_window_type_splash) {
        #ifdef SHOW_PROPERTIES
        printf("type: splash\n");
        #endif
        //frame->mode = floating;
        //if(themes->window_type[splash])
        frame->type = splash; //these have been removed because splash screens aren't managed
      }
      else if(window_type[i] == atoms->wm_window_type_dialog) {
        #ifdef SHOW_PROPERTIES
        printf("type: dialog\n");
        #endif
        frame->mode = floating;
        if(themes->window_type[dialog]) frame->theme_type = dialog;
        frame->type = dialog;
      }
      else if(window_type[i] == atoms->wm_window_type_utility) {
        #ifdef SHOW_PROPERTIES
        printf("type: utility\n");
        #endif
        frame->mode = tiling;
        if(themes->window_type[utility]) frame->theme_type = utility;
        frame->type = utility;
      }
    }
  }

  if(contents) XFree(contents);
}
Example #25
0
QPixmap KWM::icon(Window w, int width, int height){
  QPixmap result;
  Pixmap p = None;
  Pixmap p_mask = None;

  XWMHints *hints = XGetWMHints(qt_xdisplay(), w);
  if (hints && (hints->flags & IconPixmapHint)){
    p = hints->icon_pixmap;
  }
  if (hints && (hints->flags & IconMaskHint)){
    p_mask = hints->icon_mask;
  }
  if (hints)
    XFree((char*)hints);

  if (p != None){
    Window root;
    int x, y;
    unsigned int w = 0;
    unsigned int h = 0;
    unsigned int border_w, depth;
    XGetGeometry(qt_xdisplay(), p,
		 &root,
		 &x, &y, &w, &h, &border_w, &depth);
    if (w > 0 && h > 0){
      QPixmap pm(w, h, depth);
      XCopyArea(qt_xdisplay(), p, pm.handle(),
		qt_xget_temp_gc(depth==1),
		0, 0, w, h, 0, 0);
      if (p_mask != None){
	QBitmap bm(w, h);
	XCopyArea(qt_xdisplay(), p_mask, bm.handle(),
		  qt_xget_temp_gc(TRUE),
		  0, 0, w, h, 0, 0);
	pm.setMask(bm);
      }
      if (width > 0 && height > 0 && (w > (unsigned int)width
				      || h > (unsigned int) height)){
	// scale
	QWMatrix m;
	m.scale(width/(float)w, height/(float)h);
	result = pm.xForm(m);
      }
      else
	result = pm;
    }
  }
  else {
    XWMHints *hints = XGetWMHints(qt_xdisplay(),  w);
    if (hints &&
	(hints->flags & WindowGroupHint)
	&& hints->window_group != None
	&& hints->window_group != w){
      XFree((char*)hints);
      return icon(hints->window_group, width, height);
    }
    if (hints)
      XFree((char*)hints);
    Window trans = None;
    if (XGetTransientForHint(qt_xdisplay(), w, &trans)){
      if (trans != w)
	return icon(trans, width, height);
    }
  }
  return result;
}
Example #26
0
QPixmap KWM::miniIcon(Window w, int width, int height){
  static Atom a = 0;
  if (!a)
    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICON", False);
  QPixmap result;
  Pixmap p = None;
  Pixmap p_mask = None;

  long tmp[2] = {None, None};
  if (!getDoubleProperty(w, a, tmp[0], tmp[1])){
    XWMHints *hints = XGetWMHints(qt_xdisplay(), w);
    if (hints && (hints->flags & IconPixmapHint)){
      p = hints->icon_pixmap;
    }
    if (hints && (hints->flags & IconMaskHint)){
      p_mask = hints->icon_mask;
    }
    if (hints)
      XFree((char*)hints);
  }
  else {
    p = (Pixmap) tmp[0];
    p_mask = (Pixmap) tmp[1];
  }

  if (p != None){
    Window root;
    int x, y;
    unsigned int w = 0;
    unsigned int h = 0;
    unsigned int border_w, depth;
    XGetGeometry(qt_xdisplay(), p,
		 &root,
		 &x, &y, &w, &h, &border_w, &depth);
    if (w > 0 && h > 0){
      QPixmap pm(w, h, depth);
      XCopyArea(qt_xdisplay(), p, pm.handle(),
		qt_xget_temp_gc(depth==1),
		0, 0, w, h, 0, 0);
      if (p_mask != None){
	QBitmap bm(w, h);
	XCopyArea(qt_xdisplay(), p_mask, bm.handle(),
		  qt_xget_temp_gc(TRUE),
		  0, 0, w, h, 0, 0);
	pm.setMask(bm);
      }
      if (width > 0 && height > 0 && (w > (unsigned int)width
				      || h > (unsigned int) height)){
	// scale
	QWMatrix m;
	m.scale(width/(float)w, height/(float)h);
	result = pm.xForm(m);
      }
      else
	result = pm;
    }
  }
  else {
    XWMHints *hints = XGetWMHints(qt_xdisplay(),  w);
    if (hints &&
	(hints->flags & WindowGroupHint)
	&& hints->window_group != None
	&& hints->window_group != w){
	Window wg = hints->window_group;
	XFree((char*)hints);
	return miniIcon(wg, width, height);
    }
    if (hints)
      XFree((char*)hints);
    Window trans = None;
    if (XGetTransientForHint(qt_xdisplay(), w, &trans)){
      if (trans != w)
	return miniIcon(trans, width, height);
    }
  }
  return result;
}
Example #27
0
client_t *new_client(Window w)
{
    client_t *c;
    XWindowAttributes attr;
    XColor exact;
    long supplied;
    Atom win_type;

    c = malloc(sizeof *c);
    c->next = head;
    head = c;

    c->name = get_wm_name(w);
    c->win = w;
    c->frame = None;
    c->size.flags = 0;
    c->ignore_unmap = 0;
#ifdef SHAPE
    c->shaped = 0;
#endif
    c->shaded = 0;
    c->zoomed = 0;
    c->decor = 1;

    XGetWMNormalHints(dpy, c->win, &c->size, &supplied);
    XGetTransientForHint(dpy, c->win, &c->trans);

    XGetWindowAttributes(dpy, c->win, &attr);
    c->geom.x = attr.x;
    c->geom.y = attr.y;
    c->geom.w = attr.width;
    c->geom.h = attr.height;
    c->cmap = attr.colormap;
    c->old_bw = attr.border_width;

#ifdef DEBUG
    dump_name(c, "creating", 'w');
    dump_geom(c, "initial");
#endif

    XAllocNamedColor(dpy, c->cmap, opt_fg, &fg, &exact);
    XAllocNamedColor(dpy, c->cmap, opt_bg, &bg, &exact);
    XAllocNamedColor(dpy, c->cmap, opt_bd, &bd, &exact);

    if (get_atoms(c->win, net_wm_wintype, XA_ATOM, 0, &win_type, 1, NULL))
        c->decor = HAS_DECOR(win_type);

    if (get_atoms(c->win, net_wm_desk, XA_CARDINAL, 0, &c->desk, 1, NULL)) {
        if (c->desk == -1) c->desk = DESK_ALL; /* FIXME */
        if (c->desk >= ndesks && c->desk != DESK_ALL)
            c->desk = cur_desk;
    } else {
        set_atoms(c->win, net_wm_desk, XA_CARDINAL, &cur_desk, 1);
        c->desk = cur_desk;
    }
#ifdef DEBUG
    dump_info(c);
#endif

    check_states(c);

    /* We are not actually keeping the stack one in order. However, every
     * fancy panel uses it and nothing else, no matter what the spec says.
     * (I'm not sure why, as rearranging the list every time the stacking
     * changes would be distracting. GNOME's window list applet doesn't.) */
    append_atoms(root, net_client_list, XA_WINDOW, &c->win, 1);
    append_atoms(root, net_client_stack, XA_WINDOW, &c->win, 1);

    return c;
}
Example #28
0
void UpdateTransientForHint(UltimateContext *uc)
{
  if(!XGetTransientForHint(disp, uc->win, &uc->TransientFor))
    uc->TransientFor = None;
}
/*
 * "Adds" app window to the set of managed windows.
 * Actually, no data structures involved. The only thing we do is save app state
 * and register ourselves us listeners.
 * Note: User's callback is called
 */
void
xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
			       Window parent,
			       gboolean ignore_existing_state,
			       XklState * init_state)
{
	XklState state = *init_state;
	gint default_group_to_use = -1;
	GValue params[3];
	GValue rv;
	guint signal_id;

	if (toplevel_win == xkl_engine_priv(engine, root_window))
		xkl_debug(150, "??? root app win ???\n");

	xkl_debug(150,
		  "Trying to add window " WINID_FORMAT
		  "/%s with group %d\n", toplevel_win,
		  xkl_get_debug_window_title(engine, toplevel_win),
		  init_state->group);

	if (!ignore_existing_state) {
		gboolean have_state =
		    xkl_engine_get_toplevel_window_state(engine,
							 toplevel_win,
							 &state);

		if (have_state) {
			xkl_debug(150,
				  "The window " WINID_FORMAT
				  " does not require to be added, it already has the xklavier state \n",
				  toplevel_win);
			return;
		}
	}
	memset(params, 0, sizeof(params));
	g_value_init(params, XKL_TYPE_ENGINE);
	g_value_set_object(params, engine);
	g_value_init(params + 1, G_TYPE_LONG);
	g_value_set_long(params + 1, toplevel_win);
	g_value_init(params + 2, G_TYPE_LONG);
	g_value_set_long(params + 2, parent);

	memset(&rv, 0, sizeof(rv));
	g_value_init(&rv, G_TYPE_INT);
	g_value_set_int(&rv, default_group_to_use);

	signal_id =
	    g_signal_lookup("new-toplevel-window", xkl_engine_get_type());
	g_signal_emitv(params, signal_id, 0, &rv);
	default_group_to_use = g_value_get_int(&rv);
        
	if (default_group_to_use == -1) {
		Window transient_for = 0;
		if (XGetTransientForHint(xkl_engine_get_display(engine), toplevel_win, &transient_for)) {
			if (transient_for) {
				XklState trans_state;
				gboolean have_state =
					xkl_engine_get_toplevel_window_state(engine,
							 transient_for,
							 &trans_state);
				if (have_state) {
					default_group_to_use = trans_state.group;
				}
			}
		}
	}

	if (default_group_to_use == -1)
		default_group_to_use =
		    xkl_engine_priv(engine, default_group);

	if (default_group_to_use != -1)
		state.group = default_group_to_use;

	xkl_engine_save_toplevel_window_state(engine, toplevel_win,
					      &state);
	xkl_engine_select_input_merging(engine, toplevel_win,
					FocusChangeMask |
					PropertyChangeMask);

	if (default_group_to_use != -1) {
		if (xkl_engine_priv(engine, curr_toplvl_win) ==
		    toplevel_win) {
			if ((xkl_engine_priv(engine, secondary_groups_mask)
			     & (1 << default_group_to_use)) != 0)
				xkl_engine_allow_one_switch_to_secondary_group
				    (engine);
			xkl_engine_lock_group(engine,
					      default_group_to_use);
		}
	}

	if (parent == (Window) NULL)
		parent =
		    xkl_engine_get_registered_parent(engine, toplevel_win);

	xkl_debug(150, "done\n");
}
Example #30
0
void WindowManagementPrivate::activeChanged(WId w)
{
    QString caption;
    QString appName;
    QRect rect;
    bool normal = true;

    // Fetch the window size and caption.
    if (w) {
        // Synchronize against the X display and set a null error handler.
        // This is to discard error messages if the window has gone away
        // between the time that we received the active changed message
        // and when we went looking for the window details.
        Display *dpy = QX11Info::display();
        XSync(dpy, False);
        XErrorHandler oldHandler = XSetErrorHandler(nullErrorHandler);

        // Get the window size information from XGetWindowAttributes,
        // and translate the client window's top-level position to root
        // co-ordinates using XTranslateCoordinates.
        XWindowAttributes attrs;
        int x, y;
        Window child;
        memset(&attrs, 0, sizeof(attrs));
        if (XGetWindowAttributes(dpy, (Window)w, &attrs) &&
            XTranslateCoordinates(dpy, (Window)w, attrs.root, 0, 0, &x, &y, &child)) {
            rect = QRect(x, y, attrs.width, attrs.height);
        } else {
            // Window has disappeared, so wait for next active window change.
            XSync(dpy, False);
            XSetErrorHandler(oldHandler);
            return;
        }

        // Read the window caption information.
        caption = readUtf8Property(dpy, w, netWmVisibleNameAtom, utf8StringAtom);
        if (caption.isEmpty())
            caption = readUtf8Property(dpy, w, netWmNameAtom, utf8StringAtom);
        if (caption.isEmpty()) {
            // Old-style X11 application.  Retrieve WM_NAME.
            XTextProperty textProp;
            if (XGetWMName(dpy, (Window)w, &textProp)) {
                char **list;
                int count;
                if (XTextPropertyToStringList(&textProp, &list, &count)) {
                    for (int index = 0; index < count; ++index)
                        caption += QString::fromLocal8Bit(list[index]);
                    XFreeStringList(list);
                }
            }
        }

        // Read the window type to determine if it is normal, dialog, or docked.
        Atom windowType = readAtomProperty(dpy, w, netWmWindowTypeAtom);
        Window transient = 0;
        XGetTransientForHint(dpy, (Window)w, &transient);
        if (windowType) {
            normal = (windowType == netWmWindowTypeNormalAtom);
        } else {
            // No window type, so if there is a transient-for hint,
            // it is probably a dialog, otherwise normal.
            normal = (transient != 0);
        }
        if (transient != 0 && !normal) {
            // If the window is transient, but not modal, then treat it as normal.
            if (!checkForAtomProperty(dpy, w, netWmState, netWmStateModal))
                normal = true;
        }

        // Get the class hint to determine the application's name.
        XClassHint classHint;
        if (XGetClassHint(dpy, (Window)w, &classHint)) {
            appName = QString::fromLatin1(classHint.res_name);
            XFree(classHint.res_name);
            XFree(classHint.res_class);
        }

        // Monitor the window for property changes and destroy notifications.
        if (!monitoredWindows.contains(w)) {
            monitoredWindows += w;
            if (!QWidget::find(w))  // Don't select on our own windows.
                XSelectInput(dpy, (Window)w, StructureNotifyMask | PropertyChangeMask);
        }

        // Sync again to flush errors and restore the original error handler.
        XSync(dpy, False);
        XSetErrorHandler(oldHandler);

        // If the caption is "_ignore_", we should ingore this window.
        // This is used by quicklauncher.
        if (caption == QLatin1String("_ignore_"))   // No tr
            return;
    }

    // Caption should only be emitted when a normal full-screen window
    // is made active.  Dialogs and docked apps shouldn't change it.
    if (normal) {
        if (appName != prevActive || caption != prevCaption || rect != prevRect) {
            prevActive = appName;
            prevCaption = caption;
            vs->setAttribute("Caption", caption);
            QString iconName;
            QContentId cid = QContent::execToContent(appName);
            if (cid != QContent::InvalidId) {
                QContent app(cid);
                iconName = QLatin1String(":icon/")+app.iconName();
            }
            vs->setAttribute("Icon", iconName);
            emit windowCaption(caption);
        }
    }

    // Advertise the change in active window.
    bool update = false;
    if (rect != prevRect) {
        prevRect = rect;
        vs->setAttribute("Rect", rect);
        update = true;
    }
    if (caption != prevCaption) {
        prevCaption = caption;
        vs->setAttribute("Title", caption);
        update = true;
    }
    if (update) {
        emit windowActive(caption, rect, w);
    }
}