Back to index

unity  6.0.0
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
compiz::MinimizedWindowHandler Class Reference

#include <minimizedwindowhandler.h>

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

List of all members.

Public Types

typedef boost::shared_ptr
< MinimizedWindowHandler
Ptr

Public Member Functions

 MinimizedWindowHandler (Display *dpy, unsigned int xid, compiz::WindowInputRemoverLockAcquireInterface *lock_acquire)
virtual ~MinimizedWindowHandler ()
virtual void minimize ()
virtual void unminimize ()
void setVisibility (bool visible, Window shapeWin)
bool contains (boost::shared_ptr< MinimizedWindowHandler > mw)

Protected Member Functions

virtual std::vector< unsigned int > getTransients ()

Private Attributes

PrivateMinimizedWindowHandlerpriv

Detailed Description

Definition at line 37 of file minimizedwindowhandler.h.


Member Typedef Documentation

Definition at line 49 of file minimizedwindowhandler.h.


Constructor & Destructor Documentation

Definition at line 263 of file minimizedwindowhandler.cpp.

{
  priv = new PrivateMinimizedWindowHandler;

  priv->mDpy = dpy;
  priv->mXid = xid;
  priv->mLockAcquire = lock_acquire;
}

Definition at line 272 of file minimizedwindowhandler.cpp.

{
  delete priv;
}

Member Function Documentation

Definition at line 45 of file minimizedwindowhandler.cpp.

{
  for (MinimizedWindowHandler::Ptr h : priv->mTransients)
  {
    if (h->priv->mXid == mw->priv->mXid)
      return true;
  }

  return false;
}

Here is the caller graph for this function:

std::vector< unsigned int > compiz::MinimizedWindowHandler::getTransients ( ) [protected, virtual]

Reimplemented in compiz::CompizMinimizedWindowHandler< Screen, Window >.

Definition at line 72 of file minimizedwindowhandler.cpp.

{
  std::vector<unsigned int> transients;
  compiz::X11TransientForReader *reader = new compiz::X11TransientForReader (priv->mDpy, priv->mXid);

  transients = reader->getTransients();

  delete reader;

  return transients;
}

Here is the call graph for this function:

Reimplemented in compiz::CompizMinimizedWindowHandler< Screen, Window >.

Definition at line 85 of file minimizedwindowhandler.cpp.

{
  Atom          wmState = XInternAtom (priv->mDpy, "WM_STATE", 0);
  Atom          netWmState = XInternAtom (priv->mDpy, "_NET_WM_STATE", 0);
  Atom          netWmStateHidden = XInternAtom (priv->mDpy, "_NET_WM_STATE_HIDDEN", 0);
  Atom          actualType;
  int           actualFormat;
  unsigned long nItems, nLeft;
  void          *prop;
  unsigned long data[2];
  Window        root = DefaultRootWindow (priv->mDpy), parent = priv->mXid, lastParent = priv->mXid;
  Window        *children;
  unsigned int  nchildren;
  compiz::MinimizedWindowHandler::Ptr holder = compiz::MinimizedWindowHandler::Ptr (new compiz::MinimizedWindowHandler (priv->mDpy, 0, priv->mLockAcquire));
  auto          predicate_this = boost::bind (&compiz::MinimizedWindowHandler::contains, this, _1);
  auto          predicate_holder = !boost::bind (&compiz::MinimizedWindowHandler::contains, holder.get(), _1);

  std::vector<unsigned int> transients = getTransients ();

  for (unsigned int &w : transients)
  {
    compiz::MinimizedWindowHandler::Ptr p = compiz::MinimizedWindowHandler::Ptr (new compiz::MinimizedWindowHandler (priv->mDpy, w, priv->mLockAcquire));
    holder->priv->mTransients.push_back (p);
  }

  priv->mTransients.remove_if (predicate_holder);
  holder->priv->mTransients.remove_if (predicate_this);

  for (MinimizedWindowHandler::Ptr &mw : holder->priv->mTransients)
    priv->mTransients.push_back (mw);

  for (MinimizedWindowHandler::Ptr &mw : priv->mTransients)
    mw->minimize();

  do
  {
    if (XQueryTree (priv->mDpy, parent, &root, &parent, &children, &nchildren))
    {
      if (root != parent)
        lastParent = parent;
      XFree (children);
    }
    else
      root = parent;
  } while (root != parent);

  setVisibility (false, lastParent);

  /* Change the WM_STATE to IconicState */
  data[0] = IconicState;
  data[1] = None;

  XChangeProperty (priv->mDpy, priv->mXid, wmState, wmState,
                   32, PropModeReplace, (unsigned char *) data, 2);

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

      /* Don't append _NET_WM_STATE_HIDDEN */
      while (nItems--)
        if (*data++ == netWmStateHidden)
          netWmStateHidden = 0;
    }

    if (prop)
      XFree (prop);
  }

  /* Add _NET_WM_STATE_HIDDEN */
  if (netWmStateHidden)
    XChangeProperty (priv->mDpy, priv->mXid, netWmState, XA_ATOM,
                     32, PropModeAppend, (const unsigned char *) &netWmStateHidden, 1);
}

Here is the call graph for this function:

void compiz::MinimizedWindowHandler::setVisibility ( bool  visible,
Window  shapeWin 
)

Definition at line 57 of file minimizedwindowhandler.cpp.

{
  if (!visible && !priv->mRemover)
  {
    priv->mRemover = priv->mLockAcquire->InputRemover();
    if (!priv->mRemover)
      return;
  }
  else if (visible && priv->mRemover)
  {
    priv->mRemover.reset();
  }
}

Here is the caller graph for this function:

Reimplemented in compiz::CompizMinimizedWindowHandler< Screen, Window >.

Definition at line 164 of file minimizedwindowhandler.cpp.

{
  Atom          wmState = XInternAtom (priv->mDpy, "WM_STATE", 0);
  Atom          netWmState = XInternAtom (priv->mDpy, "_NET_WM_STATE", 0);
  Atom          netWmStateHidden = XInternAtom (priv->mDpy, "_NET_WM_STATE_HIDDEN", 0);
  Atom          *nextState = NULL;
  unsigned int  nextStateSize = 0;
  Atom          actualType;
  int           actualFormat;
  unsigned long nItems, nLeft;
  void          *prop;
  unsigned long data[2];
  Window        root = DefaultRootWindow (priv->mDpy), parent = priv->mXid, lastParent = priv->mXid;
  Window        *children;
  unsigned int  nchildren;
  compiz::MinimizedWindowHandler::Ptr holder = compiz::MinimizedWindowHandler::Ptr (new compiz::MinimizedWindowHandler (priv->mDpy, 0, priv->mLockAcquire));
  auto          predicate_this = boost::bind (&compiz::MinimizedWindowHandler::contains, this, _1);
  auto          predicate_holder = !boost::bind (&compiz::MinimizedWindowHandler::contains, holder.get(), _1);

  std::vector<unsigned int> transients = getTransients();

  for (unsigned int &w : transients)
  {
    compiz::MinimizedWindowHandler::Ptr p = compiz::MinimizedWindowHandler::Ptr (new compiz::MinimizedWindowHandler (priv->mDpy, w, priv->mLockAcquire));
    holder->priv->mTransients.push_back (p);
  }

  priv->mTransients.remove_if (predicate_holder);
  holder->priv->mTransients.remove_if (predicate_this);

  for (MinimizedWindowHandler::Ptr &mw : holder->priv->mTransients)
    priv->mTransients.push_back (mw);

  for (MinimizedWindowHandler::Ptr &mw : priv->mTransients)
    mw->unminimize();

  do
  {
    if (XQueryTree (priv->mDpy, parent, &root, &parent, &children, &nchildren))
    {
      if (root != parent)
        lastParent = parent;
      XFree (children);
    }
    else
      root = parent;
  } while (root != parent);

  setVisibility (true, lastParent);

  data[0] = NormalState;
  data[1] = None;

  XChangeProperty (priv->mDpy, priv->mXid, wmState, wmState,
                   32, PropModeReplace, (unsigned char *) data, 2);

  if (XGetWindowProperty (priv->mDpy, priv->mXid, netWmState, 0L, 512L, false, XA_ATOM, &actualType, &actualFormat,
                          &nItems, &nLeft, (unsigned char **) &prop) == Success)
  {
    if (actualType == XA_ATOM && actualFormat == 32 && nItems && !nLeft)
    {
      Atom *data = (Atom *) prop;
      Atom *pbegin = NULL;
      int  count = 0;

      nextStateSize = nItems;

      pbegin = nextState = (Atom *) malloc (sizeof (Atom) * nextStateSize);
      pbegin = nextState = (Atom *) memcpy (nextState, data, sizeof (Atom) * nextStateSize);

      /* Remove _NET_WM_STATE_HIDDEN */
      while (nItems--)
      {
        if (*nextState++ == netWmStateHidden)
        {
          nextState = (Atom *) memmove (nextState - 1, nextState, nItems);
          pbegin = nextState - count;

          nextStateSize--;
          pbegin = (Atom *) realloc (pbegin, sizeof (Atom) * nextStateSize);
        }

        count++;
      }

      nextState = pbegin;
    }

    XFree (prop);
  }

  /* Write new _NET_WM_STATE */
  if (nextState)
    XChangeProperty (priv->mDpy, priv->mXid, netWmState, XA_ATOM,
                     32, PropModeReplace, (const unsigned char *) nextState, nextStateSize);
  else
    XDeleteProperty (priv->mDpy, priv->mXid, netWmState);
}

Here is the call graph for this function:


Member Data Documentation


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