Back to index

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

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

Collaboration diagram for UnityMTGrabHandlesScreen:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 UnityMTGrabHandlesScreen (CompScreen *)
 ~UnityMTGrabHandlesScreen ()
void handleEvent (XEvent *)
bool toggleHandles (CompAction *action, CompAction::State state, CompOption::Vector &options)
bool showHandles (CompAction *action, CompAction::State state, CompOption::Vector &options)
bool hideHandles (CompAction *action, CompAction::State state, CompOption::Vector &options)
void optionChanged (CompOption *option, UnitymtgrabhandlesOptions::Options num)
void addHandles (const unity::MT::GrabHandleGroup::Ptr &handles)
void removeHandles (const unity::MT::GrabHandleGroup::Ptr &handles)
void addHandleWindow (const unity::MT::GrabHandle::Ptr &, Window)
void removeHandleWindow (Window)
void preparePaint (int)
void donePaint ()
void raiseHandle (const boost::shared_ptr< const unity::MT::GrabHandle > &, Window owner)
std::vector
< unity::MT::TextureSize > & 
textures ()

Public Attributes

CompositeScreen * cScreen
GLScreen * gScreen

Private Attributes

std::list
< unity::MT::GrabHandleGroup::Ptr
mGrabHandles
std::vector
< unity::MT::TextureSize
mHandleTextures
std::map< Window, const
unity::MT::GrabHandle::Ptr
mInputHandles
CompWindowVector mLastClientListStacking
Atom mCompResizeWindowAtom
bool mMoreAnimate

Detailed Description

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


Constructor & Destructor Documentation

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

                                                                :
  PluginClassHandler <UnityMTGrabHandlesScreen, CompScreen> (s),
  cScreen(CompositeScreen::get(s)),
  gScreen(GLScreen::get(s)),
  mGrabHandles(0),
  mHandleTextures(0),
  mLastClientListStacking(screen->clientList(true)),
  mCompResizeWindowAtom(XInternAtom(screen->dpy(),
                                    "_COMPIZ_RESIZE_NOTIFY", 0)),
  mMoreAnimate(false)
{
  unity::MT::GrabHandle::ImplFactory::SetDefault (new unity::MT::X11ImplFactory (screen->dpy ()));
  unity::MT::Texture::Factory::SetDefault (new unity::MT::X11TextureFactory ());

  ScreenInterface::setHandler(s);
  CompositeScreenInterface::setHandler(cScreen);
  GLScreenInterface::setHandler(gScreen);

  mHandleTextures.resize(unity::MT::NUM_HANDLES);

  for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++)
  {
    CompString fname = "handle-";
    CompString pname("unitymtgrabhandles");
    CompSize   size;

    fname = compPrintf("%s%i.png", fname.c_str(), i);
    GLTexture::List t = GLTexture::readImageToTexture(fname, pname,
                                                      size);

    (boost::shared_static_cast <unity::MT::X11TextureFactory> (unity::MT::Texture::Factory::Default ()))->setActiveWrap (t);

    mHandleTextures.at(i).first = unity::MT::Texture::Factory::Default ()->create ();
    mHandleTextures.at (i).second.width = size.width ();
    mHandleTextures.at (i).second.height = size.height ();
  }

  unity::MT::FADE_MSEC = optionGetFadeDuration ();

  optionSetToggleHandlesKeyInitiate(boost::bind(&UnityMTGrabHandlesScreen::toggleHandles, this, _1, _2, _3));
  optionSetShowHandlesKeyInitiate(boost::bind(&UnityMTGrabHandlesScreen::showHandles, this, _1, _2, _3));
  optionSetHideHandlesKeyInitiate(boost::bind(&UnityMTGrabHandlesScreen::hideHandles, this, _1, _2, _3));
  optionSetFadeDurationNotify(boost::bind(&UnityMTGrabHandlesScreen::optionChanged, this, _1, _2));
}

Here is the call graph for this function:

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

{
  mGrabHandles.clear ();
}

Member Function Documentation

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

{
  mGrabHandles.push_back(handles);
}

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

{
  mInputHandles.insert(std::pair <Window, const unity::MT::GrabHandle::Ptr> (w, h));
}

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

{
  if (mMoreAnimate)
  {
    for (const unity::MT::GrabHandleGroup::Ptr &handles : mGrabHandles)
    {
      if (handles->needsAnimate())
      {
          handles->forEachHandle ([&](const unity::MT::GrabHandle::Ptr &h)
                              {
                                h->damage (nux::Geometry (h->x (),
                                                       h->y (),
                                                       h->width (),
                                                       h->height ()));
                              });
      }
    }
  }

  cScreen->donePaint();
}
void UnityMTGrabHandlesScreen::handleEvent ( XEvent *  event)

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

{
  CompWindow* w, *oldPrev, *oldNext;

  w = oldPrev = oldNext = NULL;

  switch (event->type)
  {
    case FocusIn:
    case FocusOut:
      if (event->xfocus.mode == NotifyUngrab)
      {
       for(CompWindow * w : screen->windows())
        {
          UnityMTGrabHandlesWindow* mtwindow = UnityMTGrabHandlesWindow::get(w);
          if (mtwindow->handleTimerActive())
            mtwindow->resetTimer();
        }
      }
      break;
    case ClientMessage:

      if (event->xclient.message_type == mCompResizeWindowAtom)
      {
        CompWindow* w = screen->findWindow(event->xclient.window);

        if (w)
        {
          CompRect r;
          UMTGH_WINDOW(w);

          r.setGeometry(event->xclient.data.l[0] - w->input().left,
                        event->xclient.data.l[1] - w->input().top,
                        event->xclient.data.l[2] + w->input().left + w->input().right,
                        event->xclient.data.l[3] + w->input().top + w->input().bottom);

          uw->relayout(r, false);
        }
      }

      break;

    case PropertyNotify:

      /* Stacking order of managed clients changed, check old
       * stacking order and ensure stacking of handles
       * that were changed in the stack */


      if (event->xproperty.atom == Atoms::clientListStacking)
      {
        CompWindowVector       invalidated(0);
        CompWindowVector       clients = screen->clientList(true);
        CompWindowVector       oldClients = mLastClientListStacking;
        CompWindowVector       clientListStacking = screen->clientList(true);
        /* Windows can be removed and added from the client list
         * here at the same time (eg hide/unhide launcher ... racy)
         * so we need to check if the client list contains the same
         * windows as it used to. Sort both lists and compare ... */

        std::sort(clients.begin(), clients.end(), sortPointers);
        std::sort(oldClients.begin(),
                  oldClients.end(), sortPointers);

        if (clients != mLastClientListStacking)
          invalidated = clients;
        else
        {
          CompWindowVector::const_iterator cit = clientListStacking.begin();
          CompWindowVector::const_iterator oit = mLastClientListStacking.begin();

          for (; cit != clientListStacking.end(); cit++, oit++)
          {
            /* All clients from this point onwards in cit are invalidated
             * so splice the list to the end of the new client list
             * and update the stacking of handles there */
            if ((*cit)->id() != (*oit)->id())
            {
              invalidated.push_back((*cit));
            }
          }
        }

       for(CompWindow * w : invalidated)
         UnityMTGrabHandlesWindow::get(w)->restackHandles();

        mLastClientListStacking = clients;
      }

      break;

    case ButtonPress:
    {

      if (event->xbutton.button != 1)
        break;

      auto it = mInputHandles.find(event->xbutton.window);

      if (it != mInputHandles.end())
      {
       if (it->second)
          it->second->buttonPress (event->xbutton.x_root,
                                   event->xbutton.y_root,
                                   event->xbutton.button);
      }

      break;
    }
    case ConfigureNotify:

      w = screen->findTopLevelWindow(event->xconfigure.window);

      if (w)
        UnityMTGrabHandlesWindow::get(w)->relayout(w->inputRect(), true);

      break;

    case MapNotify:
    {

      auto it = mInputHandles.find(event->xmap.window);

      if (it != mInputHandles.end())
      {
        if (it->second)
          it->second->reposition (0, 0, unity::MT::PositionLock);
      }

      break;
    }
    default:

      break;
  }

  screen->handleEvent(event);
}

Here is the call graph for this function:

bool UnityMTGrabHandlesScreen::hideHandles ( CompAction *  action,
CompAction::State  state,
CompOption::Vector &  options 
)

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

{
  CompWindow* w = screen->findWindow(CompOption::getIntOptionNamed(options,
                                                                   "window",
                                                                   0));
  if (w)
  {
    UMTGH_WINDOW(w);

    if (!uw->allowHandles())
      return false;

    if (uw->handlesVisible())
    {
      uw->hideHandles();
      mMoreAnimate = true;
    }
  }

  return true;
}

Here is the caller graph for this function:

void UnityMTGrabHandlesScreen::optionChanged ( CompOption *  option,
UnitymtgrabhandlesOptions::Options  num 
)

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

{
  if (num == UnitymtgrabhandlesOptions::FadeDuration)
  {
    unity::MT::FADE_MSEC = optionGetFadeDuration ();
  }
}

Here is the caller graph for this function:

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

{
  if (mMoreAnimate)
  {
    mMoreAnimate = false;

    for(const unity::MT::GrabHandleGroup::Ptr &handles : mGrabHandles)
    {
      mMoreAnimate |= handles->animate(msec);
    }
  }

  cScreen->preparePaint(msec);
}
void UnityMTGrabHandlesScreen::raiseHandle ( const boost::shared_ptr< const unity::MT::GrabHandle > &  h,
Window  owner 
)

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

{
  for (const auto &pair : mInputHandles)
  {
    if (*pair.second == *h)
    {
      unsigned int mask = CWSibling | CWStackMode;
      XWindowChanges xwc;

      xwc.stack_mode = Above;
      xwc.sibling = owner;

      XConfigureWindow (screen->dpy (), pair.first, mask, &xwc);
    }
  }
}

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

{
  mGrabHandles.remove(handles);

  mMoreAnimate = true;
}

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

{
  mInputHandles.erase(w);
}
bool UnityMTGrabHandlesScreen::showHandles ( CompAction *  action,
CompAction::State  state,
CompOption::Vector &  options 
)

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

{
  CompWindow* w = screen->findWindow(CompOption::getIntOptionNamed(options,
                                                                   "window",
                                                                   0));

  bool use_timer = CompOption::getBoolOptionNamed(options, "use-timer", true);

  if (w)
  {
    UMTGH_WINDOW(w);

    if (!uw->allowHandles())
      return false;

    uw->showHandles(use_timer);

    if (!uw->handlesVisible())
      mMoreAnimate = true;
  }

  return true;
}

Here is the caller graph for this function:

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

  {
    return mHandleTextures;
  }
bool UnityMTGrabHandlesScreen::toggleHandles ( CompAction *  action,
CompAction::State  state,
CompOption::Vector &  options 
)

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

{
  CompWindow* w = screen->findWindow(CompOption::getIntOptionNamed(options,
                                                                   "window",
                                                          0));
  if (w)
  {
    UMTGH_WINDOW(w);

    if (!uw->allowHandles())
      return false;

    if (uw->handlesVisible())
      uw->hideHandles();
    else
      uw->showHandles(true);

    mMoreAnimate = true;
  }

  return true;
}

Here is the caller graph for this function:


Member Data Documentation

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

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

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

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

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

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

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

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


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