Back to index

unity  6.0.0
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
UnityMTGrabHandlesWindow Class Reference

#include <unity-mt-grab-handles.h>

Inheritance diagram for UnityMTGrabHandlesWindow:
Inheritance graph
[legend]
Collaboration diagram for UnityMTGrabHandlesWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 UnityMTGrabHandlesWindow (CompWindow *)
 ~UnityMTGrabHandlesWindow ()
bool allowHandles ()
bool handleTimerActive ()
void grabNotify (int, int, unsigned int, unsigned int)
void ungrabNotify ()
void relayout (const CompRect &, bool)
void getOutputExtents (CompWindowExtents &output)
void moveNotify (int dx, int dy, bool immediate)
bool glDraw (const GLMatrix &, GLFragment::Attrib &, const CompRegion &, unsigned int)
bool handlesVisible ()
void hideHandles ()
void showHandles (bool use_timer)
void restackHandles ()
void resetTimer ()
void disableTimer ()
virtual void raiseGrabHandle (const boost::shared_ptr< const unity::MT::GrabHandle > &)=0

Public Attributes

CompWindow * window
CompositeWindow * cWindow
GLWindow * gWindow

Protected Member Functions

void raiseGrabHandle (const boost::shared_ptr< const unity::MT::GrabHandle > &h)
void requestMovement (int x, int y, unsigned int direction, unsigned int button)

Private Member Functions

bool onHideTimeout ()

Private Attributes

unity::MT::GrabHandleGroup::Ptr mHandles
CompTimer mTimer

Detailed Description

Definition at line 201 of file unity-mt-grab-handles.h.


Constructor & Destructor Documentation

Definition at line 826 of file unity-mt-grab-handles.cpp.

                                                                :
  PluginClassHandler <UnityMTGrabHandlesWindow, CompWindow> (w),
  window(w),
  cWindow(CompositeWindow::get(w)),
  gWindow(GLWindow::get(w)),
  mHandles()
{
  WindowInterface::setHandler(window);
  CompositeWindowInterface::setHandler(cWindow);
  GLWindowInterface::setHandler(gWindow);

  mTimer.setCallback (boost::bind (&UnityMTGrabHandlesWindow::onHideTimeout, this));
}

Here is the call graph for this function:

Definition at line 840 of file unity-mt-grab-handles.cpp.

{
  mTimer.stop ();

  if (mHandles)
  {
    UnityMTGrabHandlesScreen::get(screen)->removeHandles(mHandles);
  }
}

Member Function Documentation

Definition at line 409 of file unity-mt-grab-handles.cpp.

{
  /* Not on override redirect windows */
  if (window->overrideRedirect())
    return false;

  return true;
}

Definition at line 616 of file unity-mt-grab-handles.cpp.

{
  mTimer.stop ();
}
void UnityMTGrabHandlesWindow::getOutputExtents ( CompWindowExtents &  output)

Definition at line 419 of file unity-mt-grab-handles.cpp.

{
  auto f = [&] (const unity::MT::GrabHandle::Ptr &h)
  {
    output.left = std::max (window->borderRect().left() + h->width () / 2, static_cast <unsigned int> (output.left));
    output.right = std::max (window->borderRect().right()  + h->width () / 2, static_cast <unsigned int> (output.right));
    output.top = std::max (window->borderRect().top() + h->height () / 2, static_cast <unsigned int> (output.top));
    output.bottom = std::max (window->borderRect().bottom() + h->height () / 2, static_cast <unsigned int> (output.bottom));
  };

  if (mHandles)
  {
    /* Only care about the handle on the outside */
    mHandles->forEachHandle (f);
  }
  else
    window->getOutputExtents(output);

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

Definition at line 440 of file unity-mt-grab-handles.cpp.

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

  if (mHandles && mHandles->visible())
  {
    unsigned int allowedHandles = unity::MT::getLayoutForMask (window->state (), window->actions ());
    unsigned int handle = 0;

    UMTGH_SCREEN (screen);

    for(unity::MT::TextureLayout layout : mHandles->layout (allowedHandles))
    {
      /* We want to set the geometry of the handle to the window
       * region */
      CompRegion reg = CompRegion(layout.second.x, layout.second.y, layout.second.width, layout.second.height);

      for(GLTexture * tex : boost::shared_static_cast <unity::MT::X11Texture> (layout.first)->get ())
      {
        GLTexture::MatrixList matl;
        GLTexture::Matrix     mat = tex->matrix();
        CompRegion        paintRegion(region);
#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

        /* 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();
        wAttrib.opacity = mHandles->opacity();
#else
        /* Did it succeed? */
        if (gWindow->geometry().vertices)
        {
          fragment.setOpacity(mHandles->opacity());
          /* Texture rendering set-up */
          us->gScreen->setTexEnvMode(GL_MODULATE);
#endif
          glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
          /* Draw the dim texture with all of it's modified
           * geometry glory */
          gWindow->glDrawTexture(tex,
#ifdef USE_MODERN_COMPIZ_GL
                                 transform, wAttrib,
#else
                                 fragment,
#endif
                                 mask | PAINT_WINDOW_BLEND_MASK
                                 | PAINT_WINDOW_TRANSLUCENT_MASK |
                                 PAINT_WINDOW_TRANSFORMED_MASK);
          /* Texture rendering tear-down */
          glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
#ifndef USE_MODERN_COMPIZ_GL
          us->gScreen->setTexEnvMode(GL_REPLACE);
        }
#endif
      }

      handle++;
    }
  }

  return status;
}

Here is the call graph for this function:

void UnityMTGrabHandlesWindow::grabNotify ( int  x,
int  y,
unsigned int  state,
unsigned int  mask 
)

Definition at line 547 of file unity-mt-grab-handles.cpp.

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

Definition at line 569 of file unity-mt-grab-handles.cpp.

{
  if (!mHandles)
    return false;

  return mHandles->visible();
}

Definition at line 403 of file unity-mt-grab-handles.cpp.

{
  return mTimer.active ();
}

Here is the caller graph for this function:

Definition at line 578 of file unity-mt-grab-handles.cpp.

{
  if (mHandles)
    mHandles->hide();

  window->updateWindowOutputExtents();
  cWindow->damageOutputExtents();

  disableTimer();
}
void UnityMTGrabHandlesWindow::moveNotify ( int  dx,
int  dy,
bool  immediate 
)

Definition at line 553 of file unity-mt-grab-handles.cpp.

{
  if (mHandles)
    mHandles->relayout(nux::Geometry (window->inputRect ().x (), window->inputRect ().y (),
                                      window->inputRect ().width (), window->inputRect ().height ()), false);

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

Definition at line 590 of file unity-mt-grab-handles.cpp.

{
  CompOption::Vector o (1);
  CompOption::Value  v;

  if (screen->grabbed())
    return true;

  v.set ((int) window->id ());

  o[0].setName ("window", CompOption::TypeInt);
  o[0].set (v);

  UnityMTGrabHandlesScreen::get (screen)->hideHandles (NULL, 0, o);
  return false;
}

Here is the caller graph for this function:

virtual void unity::MT::GrabHandleWindow::raiseGrabHandle ( const boost::shared_ptr< const unity::MT::GrabHandle > &  ) [pure virtual, inherited]
void UnityMTGrabHandlesWindow::raiseGrabHandle ( const boost::shared_ptr< const unity::MT::GrabHandle > &  h) [protected]

Definition at line 154 of file unity-mt-grab-handles.cpp.

{
  UnityMTGrabHandlesScreen::get (screen)->raiseHandle (h, window->frame ());
}
void UnityMTGrabHandlesWindow::relayout ( const CompRect &  r,
bool  hard 
)

Definition at line 540 of file unity-mt-grab-handles.cpp.

{
  if (mHandles)
    mHandles->relayout(nux::Geometry (r.x (), r.y (), r.width (), r.height ()), hard);
}
void UnityMTGrabHandlesWindow::requestMovement ( int  x,
int  y,
unsigned int  direction,
unsigned int  button 
) [protected, virtual]

Implements unity::MT::GrabHandleWindow.

Definition at line 160 of file unity-mt-grab-handles.cpp.

{
  /* Send _NET_MOVERESIZE to root window so that a button-1
   * press on this window will start resizing the window around */
  XEvent     event;

  if (screen->getOption("raise_on_click"))
    window->updateAttributes(CompStackingUpdateModeAboveFullscreen);

  if (window->id() != screen->activeWindow())
    if (window->focus())
      window->moveInputFocusTo();

  event.xclient.type    = ClientMessage;
  event.xclient.display = screen->dpy ();

  event.xclient.serial      = 0;
  event.xclient.send_event  = true;

  event.xclient.window       = window->id();
  event.xclient.message_type = Atoms::wmMoveResize;
  event.xclient.format       = 32;

  event.xclient.data.l[0] = x;
  event.xclient.data.l[1] = y;
  event.xclient.data.l[2] = direction;
  event.xclient.data.l[3] = button;
  event.xclient.data.l[4] = 1;

  XSendEvent(screen->dpy(), screen->root(), false,
             SubstructureRedirectMask | SubstructureNotifyMask,
             &event);
}

Definition at line 608 of file unity-mt-grab-handles.cpp.

{
  mTimer.stop ();
  mTimer.setTimes (2000, 2200);
  mTimer.start ();
}

Here is the caller graph for this function:

Definition at line 653 of file unity-mt-grab-handles.cpp.

{
  if (!mHandles)
    return;

  mHandles->forEachHandle ([&](const unity::MT::GrabHandle::Ptr &h)
                           { h->reposition (0, 0, unity::MT::PositionLock); });
}
void UnityMTGrabHandlesWindow::showHandles ( bool  use_timer)

Definition at line 622 of file unity-mt-grab-handles.cpp.

{
  UMTGH_SCREEN (screen);

  if (!mHandles)
  {
    mHandles = unity::MT::GrabHandleGroup::create (this, us->textures ());
    us->addHandles(mHandles);
  }

  if (!mHandles->visible())
  {
    unsigned int showingMask = unity::MT::getLayoutForMask (window->state (), window->actions ());
    activate();
    mHandles->show(showingMask);
    mHandles->relayout(nux::Geometry (window->inputRect().x (),
                                      window->inputRect().y (),
                                      window->inputRect().width(),
                                      window->inputRect().height()), true);

    window->updateWindowOutputExtents();
    cWindow->damageOutputExtents();
  }

  if (use_timer)
    resetTimer();
  else
    disableTimer();
}

Here is the call graph for this function:

Definition at line 563 of file unity-mt-grab-handles.cpp.

{
  window->ungrabNotify();
}

Member Data Documentation

Definition at line 214 of file unity-mt-grab-handles.h.

Definition at line 215 of file unity-mt-grab-handles.h.

Definition at line 260 of file unity-mt-grab-handles.h.

CompTimer UnityMTGrabHandlesWindow::mTimer [private]

Definition at line 261 of file unity-mt-grab-handles.h.

Definition at line 213 of file unity-mt-grab-handles.h.


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