Back to index

unity  6.0.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
compiz::X11TransientForReader Class Reference

#include <transientfor.h>

Inheritance diagram for compiz::X11TransientForReader:
Inheritance graph
[legend]
Collaboration diagram for compiz::X11TransientForReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 X11TransientForReader (Display *dpy, Window xid)
virtual ~X11TransientForReader ()
bool isTransientFor (unsigned int ancestor)
bool isGroupTransientFor (unsigned int clientLeader)
std::vector< unsigned int > getTransients ()

Static Public Attributes

static Atom wmTransientFor = None
static Atom wmClientLeader = None

Protected Member Functions

virtual unsigned int getAncestor ()

Private Attributes

PrivateX11TransientForReaderpriv

Detailed Description

Definition at line 36 of file transientfor.h.


Constructor & Destructor Documentation

compiz::X11TransientForReader::X11TransientForReader ( Display *  dpy,
Window  xid 
)

Definition at line 202 of file transientfor.cpp.

{
  priv = new PrivateX11TransientForReader ();

  priv->mXid = xid;
  priv->mDpy = dpy;

  if (!wmTransientFor)
    wmTransientFor = XInternAtom (dpy, "WM_TRANSIENT_FOR", 0);
  if (!wmClientLeader)
    wmClientLeader = XInternAtom (dpy, "WM_CLIENT_LEADER", 0);
}

Definition at line 215 of file transientfor.cpp.

{
  delete priv;
}

Member Function Documentation

unsigned int compiz::X11TransientForReader::getAncestor ( ) [protected, virtual]

Reimplemented in compiz::CompTransientForReader.

Definition at line 41 of file transientfor.cpp.

{
  Window        serverAncestor = None;
  unsigned long nItems, nLeft;
  int           actualFormat;
  Atom          actualType;
  void          *prop;

  if (XGetWindowProperty (priv->mDpy, priv->mXid, wmTransientFor, 0L, 2L, false,
                          XA_WINDOW, &actualType, &actualFormat, &nItems, &nLeft, (unsigned char **)&prop) == Success)
  {
    if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1)
    {
      Window *data = static_cast <Window *> (prop);

      serverAncestor = *data;
    }

    XFree (prop);
  }

  return serverAncestor;
}
std::vector< unsigned int > compiz::X11TransientForReader::getTransients ( )

Definition at line 152 of file transientfor.cpp.

{
  unsigned long nItems, nLeft;
  int           actualFormat;
  Atom          actualType;
  Atom          wmClientList;
  void          *prop;
  std::vector<unsigned int>   transients;
  std::vector<Window>   clientList;

  wmClientList = XInternAtom (priv->mDpy, "_NET_CLIENT_LIST", 0);

  if (XGetWindowProperty (priv->mDpy, DefaultRootWindow (priv->mDpy), wmClientList, 0L, 512L, false,
                          XA_WINDOW, &actualType, &actualFormat, &nItems, &nLeft,
                          (unsigned char **)&prop) == Success)
  {
    if (actualType == XA_WINDOW && actualFormat == 32 && nItems && !nLeft)
    {
      Window *data = static_cast <Window *> (prop);

      while (nItems--)
      {
        clientList.push_back (*data++);
      }
    }

    XFree (prop);
  }

  /* Now check all the windows in this client list
     * for the transient state (note that this won't
     * work for override redirect windows since there's
     * no concept of a client list for override redirect
     * windows, but it doesn't matter anyways in this
     * [external] case) */

  for (Window &w : clientList)
  {
    X11TransientForReader *reader = new X11TransientForReader (priv->mDpy, w);

    if (reader->isTransientFor (priv->mXid) ||
        reader->isGroupTransientFor (priv->mXid))
      transients.push_back (w);

    delete reader;
  }

  return transients;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool compiz::X11TransientForReader::isGroupTransientFor ( unsigned int  clientLeader)

Reimplemented in compiz::CompTransientForReader.

Definition at line 76 of file transientfor.cpp.

{
  Window        serverClientLeader = None;
  Window        ancestor           = getAncestor ();
  unsigned long nItems, nLeft;
  int           actualFormat;
  Atom          actualType;
  void          *prop;
  std::vector<std::string> strings;
  std::list<Atom>   atoms;

  if (!clientLeader ||
      !priv->mXid)

  if (XGetWindowProperty (priv->mDpy, priv->mXid, wmClientLeader, 0L, 2L, false,
                          XA_WINDOW, &actualType, &actualFormat, &nItems, &nLeft, (unsigned char **)&prop) == Success)
  {
    if (actualType == XA_WINDOW && actualFormat == 32 && nLeft == 0 && nItems == 1)
    {
      Window *data = static_cast <Window *> (prop);

      serverClientLeader = *data;
    }

    XFree (prop);
  }

  /* Check if the returned client leader matches
     * the requested one */
  if (serverClientLeader == clientLeader &&
      clientLeader != priv->mXid)
  {
    if (ancestor == None || ancestor == DefaultRootWindow (priv->mDpy))
    {
           Atom wmWindowType = XInternAtom (priv->mDpy, "_NET_WM_WINDOW_TYPE", 0);

           /* We need to get some common type strings */
           strings.push_back ("_NET_WM_WINDOW_TYPE_UTILITY");
           strings.push_back ("_NET_WM_WINDOW_TYPE_TOOLBAR");
           strings.push_back ("_NET_WM_WINDOW_TYPE_MENU");
           strings.push_back ("_NET_WM_WINDOW_TYPE_DIALOG");

      for (std::string &s : strings)
           {
        atoms.push_back (XInternAtom (priv->mDpy, s.c_str (), 0));
           }

           const unsigned int atomsSize = atoms.size ();

           /* Now get the window type and check to see if this is a type that we
      * should consider to be part of a window group by this client leader */

           if (XGetWindowProperty (priv->mDpy, priv->mXid, wmWindowType, 0L, 15L, false,
                              XA_ATOM, &actualType, &actualFormat, &nItems, &nLeft, (unsigned char **)&prop) == Success)
      {
        if (actualType == XA_ATOM && actualFormat == 32 && nLeft == 0 && nItems)
        {
          Atom *data = static_cast <Atom *> (prop);

          while (nItems--)
          {
            atoms.remove (*data++);
          }
        }
           }

           /* Means something was found */
           if (atomsSize != atoms.size ())
        return true;
    }
  }

  return false;
}

Here is the caller graph for this function:

bool compiz::X11TransientForReader::isTransientFor ( unsigned int  ancestor)

Reimplemented in compiz::CompTransientForReader.

Definition at line 66 of file transientfor.cpp.

{
  if (!ancestor ||
      !priv->mXid)
    return false;

  return ancestor == getAncestor ();
}

Here is the caller graph for this function:


Member Data Documentation

Reimplemented in compiz::CompTransientForReader.

Definition at line 57 of file transientfor.h.

Definition at line 49 of file transientfor.h.

Definition at line 48 of file transientfor.h.


The documentation for this class was generated from the following files: