Back to index

unity  6.0.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
UnityDialogWindow Class Reference

#include <unitydialog.h>

List of all members.

Public Member Functions

 UnityDialogWindow (CompWindow *w)
 ~UnityDialogWindow ()
bool glDraw (const GLMatrix &, GLFragment::Attrib &, const CompRegion &, unsigned int)
bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &, const CompRegion &, unsigned int)
void glAddGeometry (const GLTexture::MatrixList &matrices, const CompRegion &region, const CompRegion &clipRegion, unsigned int min, unsigned int max)
void glDrawTexture (GLTexture *texture, GLFragment::Attrib &attrib, unsigned int mask)
void windowNotify (CompWindowNotify n)
void grabNotify (int x, int y, unsigned int state, unsigned int mask)
void ungrabNotify ()
void moveNotify (int x, int y, bool immediate)
void resizeNotify (int, int, int, int)
bool place (CompPoint &)
void getAllowedActions (unsigned int &setActions, unsigned int &clearActions)
bool addTransient (CompWindow *transient)
bool removeTransient (CompWindow *transient)
bool hasParent ()
bool hasTransients ()
bool hasTransient (CompWindow *w)
CompWindow * findTopParentWindow ()
CompPoint getChildCenteredPositionForRect (CompRect rect)
CompPoint getParentCenteredPositionForRect (CompRect rect)
void moveTransientsToRect (CompWindow *skip, CompRect rect, bool)
void moveParentToRect (CompWindow *requestor, CompRect rect, bool)
void moveToRect (CompRect currentRect, bool sync)
void grabTransients (CompWindow *skip, int x, int y, unsigned int state, unsigned int mask, bool)
void grabParent (CompWindow *requestor, int x, int y, unsigned int state, unsigned int mask, bool)
void animateTransients (CompWindow *skip, CompPoint &orig, CompPoint &dest, bool cont)
void animateParent (CompWindow *requestor, CompPoint &orig, CompPoint &dest)
void setMaxConstrainingAreas ()
CompWindow * transientParent ()
void adjustIPW ()
bool animate (int ms, float fadeTime)
CompRegion getDamageRegion ()
void setIsAnimated (bool animated)
bool isAnimated ()

Public Attributes

CompWindow * window
CompositeWindow * cWindow
GLWindow * gWindow

Private Member Functions

void collectDrawInfo ()

Private Attributes

bool mSkipNotify
CompWindowList mTransients
CompWindow * mParent
CompSize mOldHintsSize
int mGrabMask
int mShadeProgress
CompPoint mTargetPos
CompPoint mCurrentPos
CompPoint mOffset
XWindowChanges mDiffXWC
Window mIpw
bool mIsAnimated

Detailed Description

Definition at line 238 of file unitydialog.h.


Constructor & Destructor Documentation

Definition at line 1537 of file unitydialog.cpp.

                                                  :
  PluginClassHandler <UnityDialogWindow, CompWindow> (w),
  window(w),
  cWindow(CompositeWindow::get(w)),
  gWindow(GLWindow::get(w)),
  mSkipNotify(false),
  mParent(NULL),
  mOldHintsSize(CompSize(0, 0)),
  mGrabMask(0),
  mShadeProgress(0),
  mIpw(None),
  mIsAnimated(false)
{
  WindowInterface::setHandler(window, true);
  GLWindowInterface::setHandler(gWindow, false);

  memset(&mDiffXWC, 0, sizeof(XWindowChanges));

  window->windowNotifySetEnabled(this, true);
}

Definition at line 1558 of file unitydialog.cpp.

{
  /* Handle weird circumstances where windows go away
   * without warning */

  UnityDialogScreen::get(screen)->untrackParent(window);

  if (mParent)
  {
    compLogMessage("unitydialog", CompLogLevelWarn, "Did not get a close notification before window was destroyed!");
    UnityDialogWindow::get(mParent)->removeTransient(window);
  }

  /* The parent went away, so make sure that
   * all the transients know about this one */
  if (mTransients.size())
  {
    compLogMessage("unitydialog", CompLogLevelWarn, "Parent got closed before transients. This is an indication of a buggy app!");
    for(CompWindow* w : mTransients)
      UnityDialogWindow::get(mParent)->removeTransient(w);
  }
}

Member Function Documentation

bool UnityDialogWindow::addTransient ( CompWindow *  transient)

Definition at line 805 of file unitydialog.cpp.

{
  bool alreadyAdded = false;
  bool newParent = false;

  if (!mTransients.size())
  {
    gWindow->glDrawSetEnabled(this, true);
    gWindow->glPaintSetEnabled(this, true);
    window->grabNotifySetEnabled(this, true);
    window->ungrabNotifySetEnabled(this, true);
    window->moveNotifySetEnabled(this, true);
    cWindow->addDamage();

    if (!mIpw)
    {
      XSetWindowAttributes attr;

      attr.override_redirect = true;

      mIpw = XCreateWindow(screen->dpy(), window->frame(), window->input().left,
                           window->input().top, window->width(), window->height(),
                           0, 0, InputOnly, CopyFromParent, CWOverrideRedirect, &attr);

      XSelectInput(screen->dpy(), mIpw, StructureNotifyMask | ButtonPressMask);

      XMapWindow(screen->dpy(), mIpw);
      adjustIPW();
    }

    mCurrentPos = mTargetPos = window->serverBorderRect().pos();

    newParent = true;
  }
  else
  {
    for (CompWindow * tw : mTransients)
      if (tw->id() == w->id())
        alreadyAdded = true;
  }

  if (!alreadyAdded)
  {
    w->grabNotifySetEnabled(this, true);
    w->ungrabNotifySetEnabled(this, true);
    w->moveNotifySetEnabled(this, true);
    w->getAllowedActionsSetEnabled(this, true);
    UnityDialogWindow::get(w)->gWindow->glPaintSetEnabled(UnityDialogWindow::get(w), !mIsAnimated);
    UnityDialogWindow::get(w)->mParent = window;
    UnityDialogWindow::get(w)->setMaxConstrainingAreas();

    screen->matchPropertyChanged(window);
    w->recalcActions();
    mTransients.push_back(w);
  }

  return newParent;
}

Here is the caller graph for this function:

Definition at line 788 of file unitydialog.cpp.

{
  XWindowChanges xwc;

  if (!mIpw)
    return;

  xwc.stack_mode = Above;
  xwc.x = window->input().left;
  xwc.y = window->input().top;
  xwc.width = window->width();
  xwc.height = window->height();

  XConfigureWindow(screen->dpy(), mIpw, CWStackMode | CWWidth | CWHeight | CWX | CWY, &xwc);
}
bool UnityDialogWindow::animate ( int  ms,
float  fadeTime 
)

Definition at line 279 of file unitydialog.cpp.

{
  if (mTransients.size() && mShadeProgress < OPAQUE)
  {
    mShadeProgress += OPAQUE * (ms / fadeTime);

    if (mShadeProgress >= OPAQUE)
      mShadeProgress = OPAQUE;

    return true;
  }
  else if (!mTransients.size() && mShadeProgress > 0)
  {
    mShadeProgress -=  OPAQUE * (ms / fadeTime);

    if (mShadeProgress <= 0)
      mShadeProgress = 0;

    return true;
  }

  return false;
}

Here is the caller graph for this function:

void UnityDialogWindow::animateParent ( CompWindow *  requestor,
CompPoint &  orig,
CompPoint &  dest 
)

Definition at line 1253 of file unitydialog.cpp.

{
  if (mParent)
  {
    if (!(mParent->state() & MAXIMIZE_STATE ||
          mParent->state() & CompWindowStateFullscreenMask))
    {
      UnityDialogWindow* udw = UnityDialogWindow::get(mParent);
      CompRect newRect(dest.x(), dest.y(), window->serverBorderRect().width(), window->serverBorderRect().height());

      udw->mTargetPos = udw->getParentCenteredPositionForRect(newRect);
      udw->mCurrentPos = CompPoint(mParent->serverBorderRect().x(), mParent->serverBorderRect().y());
      udw->mOffset = udw->mTargetPos - udw->mCurrentPos;

      udw->animateTransients(NULL, udw->mTargetPos, udw->mCurrentPos, false);
    }
  }
}

Here is the call graph for this function:

void UnityDialogWindow::animateTransients ( CompWindow *  skip,
CompPoint &  orig,
CompPoint &  dest,
bool  cont 
)

Definition at line 1229 of file unitydialog.cpp.

{
  /* Center transients (leave a bit more space
   * below) */

  for (CompWindow* cw : mTransients)
  {
    UnityDialogWindow* udw = UnityDialogWindow::get(cw);
    CompRect newRect(dest.x(), dest.y(), window->serverBorderRect().width(), window->serverBorderRect().height());

    if (cw == skip)
      return;

    udw->mTargetPos = udw->getChildCenteredPositionForRect(newRect);
    udw->mCurrentPos = CompPoint(cw->serverBorderRect().x(), cw->serverBorderRect().y());
    udw->mOffset = udw->mTargetPos - udw->mCurrentPos;

    /* New transient position is centered to this window's target position */
    if (cont)
      udw->animateTransients(NULL, udw->mTargetPos, udw->mCurrentPos, true);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file unitydialog.cpp.

{
  CompWindow*        parent = window, *nextParent = NULL;

  /* Go to the bottom most window in the stack */
  while ((nextParent = UnityDialogWindow::get(parent)->mParent))
    parent = nextParent;

  /* parent now refers to the top most window */
  return parent;
}
void UnityDialogWindow::getAllowedActions ( unsigned int &  setActions,
unsigned int &  clearActions 
)

Definition at line 773 of file unitydialog.cpp.

{
  window->getAllowedActions(setActions, clearActions);

  if (!mParent)
    return;

  clearActions |= (CompWindowActionMoveMask |
                   CompWindowActionMaximizeVertMask |
                   CompWindowActionMaximizeHorzMask |
                   CompWindowActionResizeMask);
}

Definition at line 1181 of file unitydialog.cpp.

{
  int centeredX = currentRect.x() + (currentRect.width() / 2 -
                                     window->serverBorderRect().width() / 2);
  int centeredY = currentRect.y() + (currentRect.height() / 2 -
                                     window->serverBorderRect().height() / 2);

  return CompPoint(centeredX, centeredY);
}

Here is the caller graph for this function:

Definition at line 305 of file unitydialog.cpp.

{
  CompRect damageBounds;
  float progress = mShadeProgress / (float) OPAQUE;

  /* Current rect in animation expanded by output + 5 */
  damageBounds.setX(mCurrentPos.x() +
                    ((mTargetPos.x() - mCurrentPos.x()) * progress));
  damageBounds.setY(mCurrentPos.y() +
                    ((mTargetPos.y() - mCurrentPos.y()) * progress));
  damageBounds.setWidth(window->serverOutputRect().width() + 5);
  damageBounds.setHeight(window->serverOutputRect().height() + 5);

  return CompRegion(damageBounds);
}

Here is the caller graph for this function:

Definition at line 1192 of file unitydialog.cpp.

{
  int centeredX = currentRect.x() + (currentRect.width() / 2 -
                                     window->serverBorderRect().width() / 2);
  int centeredY = currentRect.y() + (currentRect.height() / 2 -
                                     window->serverBorderRect().height() / 2);

  return CompPoint(centeredX, centeredY);
}

Here is the caller graph for this function:

void UnityDialogWindow::glAddGeometry ( const GLTexture::MatrixList &  matrices,
const CompRegion &  region,
const CompRegion &  clipRegion,
unsigned int  min,
unsigned int  max 
)

Definition at line 409 of file unitydialog.cpp.

{
  unity::PaintInfoCollector::Active ()->processGeometry (matrices, region, min, max);

  gWindow->glAddGeometry(matrices, region, clipRegion, min, max);
}

Here is the call graph for this function:

bool UnityDialogWindow::glDraw ( const GLMatrix &  transform,
GLFragment::Attrib &  fragment,
const CompRegion &  region,
unsigned int  mask 
)

Definition at line 646 of file unitydialog.cpp.

{
  /* We want to set the geometry of the dim to the window
   * region */
  CompRegion reg = CompRegion(window->x(), window->y(), window->width(), window->height());
  CompRegion        paintRegion(region);

  /* Draw the window on the bottom, we will be drawing the
   * dim render on top */
  bool status = gWindow->glDraw(transform,
#ifdef USE_MODERN_COMPIZ_GL
                                attrib,
#else
                                fragment,
#endif
                                region, mask);

  UNITY_DIALOG_SCREEN(screen);

  for (GLTexture* tex : uds->tex())
  {
    GLTexture::MatrixList matl;
    GLTexture::Matrix     mat = tex->matrix();
#ifdef USE_MODERN_COMPIZ_GL
    GLWindowPaintAttrib   wAttrib(attrib);
#endif

    /* We can reset the window geometry since it will be
     * re-added later */
#ifdef USE_MODERN_COMPIZ_GL
    gWindow->vertexBuffer()->begin();
#else
    gWindow->geometry().reset();
#endif

    /* Scale the dim render by the ratio of dim size
     * to window size */
    mat.xx *= (4) / window->width();
    mat.yy *= (4) / window->height();

    /* Not sure what this does, but it is necessary
     * (adjusts for scale?) */
    mat.x0 -= mat.xx * reg.boundingRect().x1();
    mat.y0 -= mat.yy * reg.boundingRect().y1();

    matl.push_back(mat);

    if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
      paintRegion = infiniteRegion;

    /* Now allow plugins to mess with the geometry of our
     * dim (so we get a nice render for things like
     * wobbly etc etc */
    gWindow->glAddGeometry(matl, reg, paintRegion);
#ifdef USE_MODERN_COMPIZ_GL
    gWindow->vertexBuffer()->end();
#endif

#ifdef USE_MODERN_COMPIZ_GL
    unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
    wAttrib.opacity = mShadeProgress;
    /* Texture rendering set-up */
//    uds->gScreen->setTexEnvMode(GL_MODULATE);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    /* Draw the dim texture with all of it's modified
     * geometry glory */
    gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
    gWindow->glDrawTexture(tex, transform, attrib, mask
                                              | PAINT_WINDOW_BLEND_MASK
                                              | PAINT_WINDOW_TRANSLUCENT_MASK
                                              | PAINT_WINDOW_TRANSFORMED_MASK);
    gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
    /* Texture rendering tear-down */
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    uds->gScreen->setTexEnvMode(GL_REPLACE);
#else
    /* Did it succeed? */
    if (gWindow->geometry().vertices)
    {
      unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
      fragment.setOpacity(mShadeProgress);
      /* Texture rendering set-up */
      uds->gScreen->setTexEnvMode(GL_MODULATE);
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
      /* Draw the dim texture with all of it's modified
       * geometry glory */
      gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
      gWindow->glDrawTexture(tex, fragment, mask | PAINT_WINDOW_BLEND_MASK
                             | PAINT_WINDOW_TRANSLUCENT_MASK |
                             PAINT_WINDOW_TRANSFORMED_MASK);
      gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
      /* Texture rendering tear-down */
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
      uds->gScreen->setTexEnvMode(GL_REPLACE);
    }
#endif
  }

  for (CompWindow* w : mTransients)
  {
    if (GLWindow::get(w)->textures().empty())
      GLWindow::get(w)->bind();

    if (!UnityDialogWindow::get(w)->mIsAnimated)
    {
      unity::PaintInfoCollector pc (w);

      pc.collect();
      pc.drawGeometriesForWindow (window,
#ifdef USE_MODERN_COMPIZ_GL
                                  transform,
#endif
                                  mask);
    }
  }

  return status;
}

Here is the call graph for this function:

void UnityDialogWindow::glDrawTexture ( GLTexture *  texture,
GLFragment::Attrib &  attrib,
unsigned int  mask 
)

Definition at line 422 of file unitydialog.cpp.

Here is the call graph for this function:

bool UnityDialogWindow::glPaint ( const GLWindowPaintAttrib &  attrib,
const GLMatrix &  transform,
const CompRegion &  region,
unsigned int  mask 
)

Definition at line 377 of file unitydialog.cpp.

{
  GLMatrix wTransform(transform);

  if (mParent)
    mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;

  if (mTargetPos != mCurrentPos)
  {
    float progress = mShadeProgress / (float) OPAQUE;
    mask |= PAINT_WINDOW_TRANSFORMED_MASK;

    int dx = ((mTargetPos.x() - mCurrentPos.x()) * progress);
    int dy = ((mTargetPos.y() - mCurrentPos.y()) * progress);

    dx += mCurrentPos.x() - window->serverBorderRect().x();
    dy += mCurrentPos.y() - window->serverBorderRect().y();

    wTransform.translate(dx, dy, 0);

    if (mShadeProgress == OPAQUE)
      mTargetPos = mCurrentPos;
  }

  return gWindow->glPaint(attrib, wTransform, region, mask);
}
void UnityDialogWindow::grabNotify ( int  x,
int  y,
unsigned int  state,
unsigned int  mask 
)

Definition at line 996 of file unitydialog.cpp.

{
  mGrabMask = mask;

  window->grabNotify(x, y, state, mask);

  if (!mSkipNotify && (mask & CompWindowGrabMoveMask))
  {
    moveTransientsToRect(NULL, window->serverBorderRect(), true);

    grabTransients(NULL, x, y, state, mask, true);
  }
}

Here is the caller graph for this function:

void UnityDialogWindow::grabParent ( CompWindow *  requestor,
int  x,
int  y,
unsigned int  state,
unsigned int  mask,
bool   
)
void UnityDialogWindow::grabTransients ( CompWindow *  skip,
int  x,
int  y,
unsigned int  state,
unsigned int  mask,
bool  grab 
)

Definition at line 1203 of file unitydialog.cpp.

{
  /* Center transients (leave a bit more space
   * below) */

  for (CompWindow* cw : mTransients)
  {
    UnityDialogWindow* udw = UnityDialogWindow::get(cw);

    if (cw == skip)
      return;

    udw->mSkipNotify = true;

    if (grab)
      udw->grabNotify(x, y, state, mask);
    else
      udw->ungrabNotify();

    udw->mSkipNotify = false;
  }
}

Here is the call graph for this function:

bool UnityDialogWindow::hasParent ( ) [inline]

Definition at line 304 of file unitydialog.h.

  {
    return mParent != NULL;
  }
bool UnityDialogWindow::hasTransient ( CompWindow *  w) [inline]

Definition at line 312 of file unitydialog.h.

  {
    return std::find(mTransients.begin(),
                     mTransients.end(),
                     w) == mTransients.end();
  }

Here is the caller graph for this function:

Definition at line 308 of file unitydialog.h.

  {
    return !mTransients.empty();
  }

Here is the caller graph for this function:

bool UnityDialogWindow::isAnimated ( ) [inline]

Definition at line 351 of file unitydialog.h.

  {
    return mIsAnimated;
  }
void UnityDialogWindow::moveNotify ( int  x,
int  y,
bool  immediate 
)

Definition at line 1047 of file unitydialog.cpp.

{
  window->moveNotify(dx, dy, immediate);

  if (!mSkipNotify)
  {
    if (mParent && UnityDialogScreen::get(screen)->switchingVp() &&
        !(mGrabMask & CompWindowGrabMoveMask))
    {
      moveParentToRect(window, window->serverBorderRect(), true);
    }
    else if (mParent)
    {
      moveToRect(mParent->serverBorderRect(), true);
    }
    else
      moveTransientsToRect(window, window->serverBorderRect(), true);
  }
}
void UnityDialogWindow::moveParentToRect ( CompWindow *  requestor,
CompRect  rect,
bool  sync 
)

Definition at line 1292 of file unitydialog.cpp.

{
  if (mParent)
  {
    if (!(mParent->state() & MAXIMIZE_STATE ||
          mParent->state() & CompWindowStateFullscreenMask))
    {
      CompPoint centeredPos = UnityDialogWindow::get(mParent)->getParentCenteredPositionForRect(rect);
      UnityDialogWindow::get(mParent)->mSkipNotify = true;

      /* Move the parent window to the requested position */
      mParent->move(centeredPos.x() - mParent->borderRect().x(),
                    centeredPos.y() - mParent->borderRect().y(), true);

      if (sync)
        mParent->syncPosition();

      UnityDialogWindow::get(mParent)->mSkipNotify = false;

      UnityDialogWindow::get(mParent)->moveTransientsToRect(requestor, window->serverBorderRect(), sync);
      UnityDialogWindow::get(mParent)->moveParentToRect(window, window->serverBorderRect(), sync);
    }
  }

}
void UnityDialogWindow::moveToRect ( CompRect  currentRect,
bool  sync 
)

Definition at line 76 of file unitydialog.cpp.

{
  CompPoint pos = getChildCenteredPositionForRect(currentRect);

  mSkipNotify = true;
  window->move(pos.x() - window->borderRect().x(),
               pos.y() - window->borderRect().y(), true);

  if (sync)
    window->syncPosition();

  setMaxConstrainingAreas();
  mSkipNotify = false;
}

Here is the call graph for this function:

void UnityDialogWindow::moveTransientsToRect ( CompWindow *  skip,
CompRect  rect,
bool  sync 
)

Definition at line 1273 of file unitydialog.cpp.

{
  /* Center transients (leave a bit more space
   * below) */

  for (CompWindow* cw : mTransients)
  {
    if (cw == skip)
      return;

    UnityDialogWindow::get(cw)->moveToRect(currentRect, sync);

    /* Sync all of this window's transients */
    if (UnityDialogWindow::get(cw)->mTransients.size())
      UnityDialogWindow::get(cw)->moveTransientsToRect(NULL, cw->serverBorderRect(), sync);
  }
}

Here is the caller graph for this function:

bool UnityDialogWindow::place ( CompPoint &  pos)

Definition at line 1367 of file unitydialog.cpp.

{
  CompWindow* parent;

  /* If this window is a transient for some other window,
   * increment the transient count and
   * enable the dimming on that other window */

  if ((parent = transientParent()) != NULL)
    if (UnityDialogWindow::get(parent)->addTransient(window))
      UnityDialogScreen::get(screen)->trackParent(parent);

  /* We need to check the final parent window */

  if (mParent)
  {
    CompWindow::Geometry transientGeometry;
    CompRegion transientPos, outputRegion, outsideArea, outsideRegion;
    pos = getChildCenteredPositionForRect(mParent->serverBorderRect());
    int    hdirection, vdirection;

    transientGeometry = CompWindow::Geometry(pos.x(),
                                             pos.y(),
                                             window->borderRect().width(),
                                             window->borderRect().height(), 0);

    transientPos = CompRegion((CompRect) transientGeometry);
    outputRegion = screen->workArea();
    outsideRegion = outputRegion;

    /* Create a w->width () px region outside of the output region */
    outsideRegion.shrink(-window->borderRect().width(), -window->borderRect().height());

    outsideRegion -= outputRegion;

    if (!(outsideArea = transientPos.intersected(outsideRegion)).isEmpty())
    {
      CompRect   transientRect;
      CompPoint  orig, dest;
      int width;
      int height;

      hdirection = outsideArea.boundingRect().x() < 0 ? 1 : -1;
      vdirection = outsideArea.boundingRect().y() < 0 ? 1 : -1;

      width  = outsideArea.boundingRect().width() >=
               window->serverBorderRect().width() ? 0 :
               outsideArea.boundingRect().width() * hdirection;
      height = outsideArea.boundingRect().height() >=
               window->serverBorderRect().height() ? 0 :
               outsideArea.boundingRect().height() * vdirection;

      pos += CompPoint(width, height);
      transientPos = CompRegion(pos.x(),
                                pos.y(),
                                window->serverBorderRect().width(), window->serverBorderRect().height());
      transientRect = transientPos.boundingRect();

      dest = CompPoint(transientRect.x(), transientRect.y());
      orig = CompPoint(mParent->serverBorderRect().x(), mParent->serverBorderRect().y());

      animateParent(window, orig, dest);

      moveParentToRect(window, transientRect, true);

    }

    pos -= CompPoint(window->border().left, window->border().top);

    return true;
  }

  return window->place(pos);
}
bool UnityDialogWindow::removeTransient ( CompWindow *  transient)

Definition at line 865 of file unitydialog.cpp.

{
  mTransients.remove(w);

  w->grabNotifySetEnabled(this, false);
  w->ungrabNotifySetEnabled(this, false);
  w->moveNotifySetEnabled(this, false);
  w->getAllowedActionsSetEnabled(this, false);
  UnityDialogWindow::get(w)->mParent = NULL;
  screen->matchPropertyChanged(window);
  w->recalcActions();

  if (!mTransients.size())
  {
    XWindowChanges xwc;
    unsigned int   mask = 0;

    window->ungrabNotifySetEnabled(this, false);
    window->grabNotifySetEnabled(this, false);
    window->moveNotifySetEnabled(this, false);

    if (mIpw)
    {
      XDestroyWindow(screen->dpy(), mIpw);
      mIpw = None;
    }

    if (mDiffXWC.width)
    {
      xwc.width = window->width() - mDiffXWC.width;
      mask |= CWWidth;
    }

    if (mDiffXWC.height)
    {
      xwc.height = window->height() - mDiffXWC.height;
      mask |= CWHeight;
    }

    if (mask)
      window->configureXWindow(mask, &xwc);

    cWindow->addDamage();
    window->move(-mOffset.x() - mDiffXWC.x, -mOffset.y() - mDiffXWC.y, true);
    window->syncPosition();
    cWindow->addDamage();

    memset(&mDiffXWC, 0, sizeof(XWindowChanges));

    mCurrentPos = CompPoint(window->serverBorderRect().x(), window->serverBorderRect().y());
    mTargetPos = mCurrentPos + mOffset;
    mOffset = CompPoint(0, 0);

    return true;
  }

  return false;
}
void UnityDialogWindow::resizeNotify ( int  dx,
int  dy,
int  dwidth,
int  dheight 
)

Definition at line 1027 of file unitydialog.cpp.

{
  window->resizeNotify(dx, dy, dwidth, dheight);

  /* The window resized was a parent window, re-center transients */
  if (!mSkipNotify)
  {
    moveTransientsToRect(NULL, window->serverBorderRect(), true);

    if (mIpw)
      adjustIPW();

    if (mParent)
      UnityDialogWindow::get(mParent)->moveTransientsToRect(NULL, mParent->serverBorderRect(), true);
  }
}
void UnityDialogWindow::setIsAnimated ( bool  animated) [inline]

Definition at line 347 of file unitydialog.h.

  {
    mIsAnimated = animated;
  }

Definition at line 1068 of file unitydialog.cpp.

{
  /* Don't set maximum size hints if they are already set to a value
   * that is lower than ours (unlikely, but it has a chance of
   * happening so we need to handle this case)
   *
   * Also, core will set max_width to the same as min_width in the
   * case that somehow our requested max_width < min_width, so
   * detect this case too.
   *
   * In the case where we're goign to make the dialog window smaller
   * than it actually is, don't allow this, instead make parent window
   * at least 1.25x bigger than the dialog window and set the maximum
   * size of the dialog window to 0.8x the parent window
   */

  bool sizeHintsSet = false;
  bool needsWidth, needsHeight;
  XWindowChanges xwc;
  unsigned int   changeMask = 0;

  if (!(mParent->state() & MAXIMIZE_STATE ||
        mParent->state() & CompWindowStateFullscreenMask))
  {

    if (mParent->serverBorderRect().width() < window->serverBorderRect().width() * 1.25)
    {
      xwc.width = window->serverBorderRect().width() * 1.25;
      xwc.x = mParent->x() - ((window->serverBorderRect().width() * 1.25) -
                              (mParent->serverBorderRect().width())) / 2.0;

      /* Don't ever put the parent window offscreen */
      if (xwc.x < screen->workArea().left() + mParent->border().left)
        xwc.x = screen->workArea().left() + mParent->border().left;
      else if (xwc.x + xwc.width > screen->workArea().right() - mParent->border().right)
        xwc.x = screen->workArea().right() - xwc.width - mParent->border().right;

      if (!UnityDialogWindow::get(mParent)->mDiffXWC.width)
        UnityDialogWindow::get(mParent)->mDiffXWC.width = xwc.width - mParent->width();
      if (!UnityDialogWindow::get(mParent)->mDiffXWC.x)
      {
        UnityDialogWindow::get(mParent)->mDiffXWC.x = xwc.x - mParent->x();
        (UnityDialogWindow::get(mParent))->mCurrentPos += CompPoint(UnityDialogWindow::get(mParent)->mDiffXWC.x, 0);
        (UnityDialogWindow::get(mParent))->mTargetPos += CompPoint(UnityDialogWindow::get(mParent)->mDiffXWC.x, 0);
      }

      changeMask |= CWX | CWWidth;
    }

    if (mParent->serverBorderRect().height() < window->serverBorderRect().height() * 1.25)
    {
      xwc.height = window->serverBorderRect().height() * 1.25;
      xwc.y = mParent->y() - ((window->serverBorderRect().height() * 1.25) -
                              (mParent->serverBorderRect().height())) / 2.0;

      /* Don't ever put the parent window offscreen */
      if (xwc.y < screen->workArea().top() + mParent->border().top)
        xwc.y = screen->workArea().top() + mParent->border().top;
      else if (xwc.y + xwc.height > screen->workArea().bottom() - mParent->border().bottom)
        xwc.y = screen->workArea().bottom() - xwc.height - mParent->border().bottom;

      if (!UnityDialogWindow::get(mParent)->mDiffXWC.height)
        UnityDialogWindow::get(mParent)->mDiffXWC.height = xwc.height - mParent->height();
      if (!UnityDialogWindow::get(mParent)->mDiffXWC.y)
      {
        UnityDialogWindow::get(mParent)->mDiffXWC.y = xwc.y - mParent->y();
        (UnityDialogWindow::get(mParent))->mCurrentPos += CompPoint(0, UnityDialogWindow::get(mParent)->mDiffXWC.y);
        (UnityDialogWindow::get(mParent))->mTargetPos += CompPoint(0, UnityDialogWindow::get(mParent)->mDiffXWC.y);
      }

      changeMask |= CWY | CWHeight;
    }

  }

  if (changeMask)
    mParent->configureXWindow(changeMask, &xwc);

  needsWidth = mOldHintsSize.width() != window->sizeHints().max_width;

  if (needsWidth)
    needsWidth = !(mOldHintsSize.width() && window->sizeHints().max_width ==
                   window->sizeHints().min_width);

  needsHeight = mOldHintsSize.height() != window->sizeHints().max_height;

  if (needsHeight)
    needsHeight = !(mOldHintsSize.height() && window->sizeHints().max_height ==
                    window->sizeHints().min_height);

  if (mParent && (window->sizeHints().flags & PMaxSize) && needsWidth && needsHeight)
  {
    sizeHintsSet |= ((window->sizeHints().max_width <
                      mParent->serverGeometry().width() * 0.8) ||
                     (window->sizeHints().max_height <
                      mParent->serverGeometry().height() * 0.8));
  }

  if (mParent && (!sizeHintsSet))
  {
    XSizeHints sizeHints = window->sizeHints();

    sizeHints.flags |= PMaxSize;
    sizeHints.max_width = mParent->serverGeometry().width() * 0.8;
    sizeHints.max_height = mParent->serverGeometry().height() * 0.8;

    mOldHintsSize = CompSize(sizeHints.max_width, sizeHints.max_height);
    XSetWMNormalHints(screen->dpy(), window->id(), &sizeHints);
  }
}

Here is the caller graph for this function:

Definition at line 1321 of file unitydialog.cpp.

{
  if (window->transientFor() &&
      window->state() & CompWindowStateModalMask &&
      !UnityDialogScreen::get(screen)->optionGetAvoidMatch().evaluate(window))
  {
    Window xid = window->transientFor();

    /* Some stupid applications set the WM_TRANSIENT_FOR to an unmapped window
     * but one that is strangely still managed *cough*qt*cough*. Those applications
     * deserve to be shot. In any case, we'll need to work around that by assuming
     * that this is a modal dialog with *a* parent, so go for the largest window
     * in this client group that's not a transient for anything */

    CompWindow* parent = screen->findWindow(xid);

    if (!parent->isViewable() || parent->overrideRedirect())
    {
      compLogMessage("unitydialog", CompLogLevelWarn, "window 0x%x sets WM_TRANSIENT_FOR" \
                     " in a strange way. Workaround around.\n", window->id());
      if (parent->clientLeader())
      {
        CompWindow* candidate = parent;

       for (CompWindow* w : screen->windows())
          if (w->clientLeader() == parent->clientLeader() &&
              w->isViewable() && !w->overrideRedirect() &&
              (w->geometry().width() * w->geometry().height()) >
              (candidate->geometry().width() * candidate->geometry().height()))
            candidate = w;

        if (candidate != parent)
          parent = candidate;
        else
          parent = NULL;
      }
    }

    if (parent)
      return parent;
  }

  return NULL;
}

Here is the caller graph for this function:

Definition at line 1013 of file unitydialog.cpp.

{
  mGrabMask = 0;

  window->ungrabNotify();

  if (!mSkipNotify)
  {
    moveTransientsToRect(NULL, window->serverBorderRect(), true);
    grabTransients(NULL, 0, 0, 0, 0, false);
  }
}

Here is the caller graph for this function:

void UnityDialogWindow::windowNotify ( CompWindowNotify  n)

Definition at line 969 of file unitydialog.cpp.

{
  switch (n)
  {
    case CompWindowNotifyClose:

      /* If this window was a transient for some other window
         * then decrement the transient count */

      if (mParent)
        UnityDialogWindow::get(mParent)->removeTransient(window);

      break;

    case CompWindowNotifyFrameUpdate:

      if (mParent)
        moveToRect(mParent->serverBorderRect(), true);

    default:
      break;
  }

  window->windowNotify(n);
}

Member Data Documentation

CompositeWindow* UnityDialogWindow::cWindow

Definition at line 251 of file unitydialog.h.

Definition at line 252 of file unitydialog.h.

CompPoint UnityDialogWindow::mCurrentPos [private]

Definition at line 365 of file unitydialog.h.

XWindowChanges UnityDialogWindow::mDiffXWC [private]

Definition at line 367 of file unitydialog.h.

Definition at line 362 of file unitydialog.h.

Window UnityDialogWindow::mIpw [private]

Definition at line 368 of file unitydialog.h.

Definition at line 369 of file unitydialog.h.

CompPoint UnityDialogWindow::mOffset [private]

Definition at line 366 of file unitydialog.h.

Definition at line 361 of file unitydialog.h.

CompWindow* UnityDialogWindow::mParent [private]

Definition at line 360 of file unitydialog.h.

Definition at line 363 of file unitydialog.h.

Definition at line 358 of file unitydialog.h.

CompPoint UnityDialogWindow::mTargetPos [private]

Definition at line 364 of file unitydialog.h.

CompWindowList UnityDialogWindow::mTransients [private]

Definition at line 359 of file unitydialog.h.

Definition at line 250 of file unitydialog.h.


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