コード例 #1
0
void
MagScreen::positionUpdate (const CompPoint &pos)
{
    damageRegion ();

    posX = pos.x ();
    posY = pos.y ();

    damageRegion ();
}
コード例 #2
0
ファイル: text.cpp プロジェクト: CannedFish/deepin-compiz
bool
CompText::renderWindowTitle (Window               window,
		             bool                 withViewportNumber,
		             const CompText::Attrib &attrib)
{
    CompString text;

    TEXT_SCREEN (screen);

    if (!ts)
	return false;

    if (withViewportNumber)
    {
	CompString title;
    	CompPoint  winViewport;
	CompSize   viewportSize;

	title = ts->getWindowName (window);
	if (!title.empty ())
	{
	    CompWindow *w;

	    w = screen->findWindow (window);
	    if (w)
	    {
		int viewport;

		winViewport  = w->defaultViewport ();
		viewportSize = screen->vpSize ();
		viewport = winViewport.y () * viewportSize.width () +
		           winViewport.x () + 1;
		text = compPrintf ("%s -[%d]-", title.c_str (), viewport);
	    }
	    else
	    {
		text = title;
	    }
	}
    }
    else
    {
	text = ts->getWindowName (window);
    }

    if (text.empty ())
	return false;

    return renderText (text, attrib);
}
コード例 #3
0
void GrabEdge::ButtonDownEvent(CompPoint const& p, unsigned button, Time timestamp)
{
  if (button != 1)
  {
    if (button == 2 || button == 3)
      PerformWMAction(p, button, timestamp);

    return;
  }

  if (!IsMaximizable() && !always_wait_grab_timeout_)
  {
    Edge::ButtonDownEvent(p, button, timestamp);
    return;
  }

  auto const& style = Style::Get();
  unsigned max_time_delta = std::max(0, style->DoubleClickMaxTimeDelta());
  bool double_clicked = false;

  if (timestamp - last_click_time_ < max_time_delta)
  {
    int max_distance = style->DoubleClickMaxDistance();

    if (std::abs(p.x() - last_click_pos_.x()) < max_distance &&
        std::abs(p.y() - last_click_pos_.y()) < max_distance)
    {
      PerformWMAction(p, button, timestamp);
      double_clicked = true;
      button_down_timer_.reset();
    }
  }

  if (!double_clicked)
  {
    button_down_timer_.reset(new glib::Timeout(style->grab_wait()));
    button_down_timer_->Run([this] {
      Edge::ButtonDownEvent(CompPoint(pointerX, pointerY), button_down_, last_click_time_);
      button_down_timer_.reset();
      return false;
    });
  }

  button_down_ = button;
  last_click_pos_ = p;
  last_click_time_ = timestamp;
}
コード例 #4
0
ファイル: wall.cpp プロジェクト: adrianobalani/compiz-2
bool
WallScreen::checkDestination (unsigned int destX,
			      unsigned int destY)
{
    CompPoint point;
    CompSize  size;

    point = screen->vp ();
    size = screen->vpSize ();

    if (point.x () - destX >= (unsigned int) size.width ())
	return false;

    if (point.y () - destY >= (unsigned int) size.height ())
	return false;

    return true;
}
コード例 #5
0
ファイル: keynav.cpp プロジェクト: ssmccoy/compiz-keynav
bool
KeyboardNavigation::NearestWindow::lateralCollision (CompWindow *window)
{
    CompPoint center ( window->x() + (window->width() / 2),
                       window->y() + (window->height() / 2) );

    switch (direction) {
        case FOCUS_UP:
        case FOCUS_DOWN:
            return center.x() >= source->x() &&
                   center.x() <= source->x() + source->width();
        case FOCUS_LEFT:
        case FOCUS_RIGHT:
            return center.y() >= source->y() &&
                   center.y() <= source->y() + source->height();
    }

    throw "Illegal State";
}
コード例 #6
0
ファイル: wall.cpp プロジェクト: adrianobalani/compiz-2
void
WallWindow::activate ()
{
    WALL_SCREEN (screen);

    if (window->placed () && !screen->otherGrabExist ("wall", "switcher", 0))
    {
	int       dx, dy;
	CompPoint viewport;

	screen->viewportForGeometry (window->geometry (), viewport);
	dx       = viewport.x ();
	dy       = viewport.y ();

	/* Handle negative value */
	dx = (unsigned int) dx % screen->vpSize ().width ();
	dy = (unsigned int) dy % screen->vpSize ().height ();

	dx -= screen->vp ().x ();
	dy -= screen->vp ().y ();

	if (dx || dy)
	{
	    XWindowChanges xwc;
	    unsigned int   mask = 0;

	    /* If changing viewports fails we should not
	     * move the client window */
	    if (!ws->moveViewport (-dx, -dy, false))
	    {
		window->activate ();
		return;
	    }

	    ws->focusDefault = false;

	    CompRegion screenRegion;

	    foreach (const CompOutput &o, screen->outputDevs ())
		screenRegion += o.workArea ();

	    CompPoint d = compiz::wall::movementWindowOnScreen (window->serverBorderRect (),
								screenRegion);

	    mask |= d.x () !=0 ? CWX : 0;
	    mask |= d.y () !=0 ? CWY : 0;

	    xwc.x = window->serverGeometry ().x () + d.x ();
	    xwc.y = window->serverGeometry ().y () + d.y ();

	    window->configureXWindow (mask, &xwc);
	}
コード例 #7
0
ファイル: keynav.cpp プロジェクト: ssmccoy/compiz-keynav
int
KeyboardNavigation::NearestWindow::distanceFrom (CompWindow *window)
{
    DEBUG_LOG("calculating " << direction << " distance to " << window->id());

    CompPoint center ( window->x() + (window->width() / 2),
                       window->y() + (window->height() / 2) );

    switch (direction) {
        case FOCUS_DOWN:
            return center.y() - start.y();
        case FOCUS_LEFT:
            return start.x() - center.x();
        case FOCUS_RIGHT:
            return center.x() - start.x();
        case FOCUS_UP:
            return start.y() - center.y();
    }

    throw "Illegal State";
}
コード例 #8
0
	void
	calculateWallOffset (const CompRect  &output,
			     const CompPoint &offsetInScreenCoords,
			     const CompPoint &vpSize,
			     const CompSize  &screenSize,
			     float           &offsetInWorldX,
			     float           &offsetInWorldY,
			     float	     &worldScaleFactorX,
			     float	     &worldScaleFactorY,
			     float           animationProgress)
	{
	    const float sx = screenSize.width () / static_cast <float> (output.width ());
	    const float sy = screenSize.height () / static_cast <float> (output.height ());
	    offsetInWorldX = 0.0;
	    offsetInWorldY = 0.0;
	    worldScaleFactorX = 1.0f;
	    worldScaleFactorY = 1.0f;

	    if (output.left () == 0)
	    {
		offsetInWorldX = ((vpSize.x () * sx) / ((float) output.width ()) * (offsetInScreenCoords.x ()) * animationProgress);
		worldScaleFactorX = 1.0f - ((float) (offsetInScreenCoords.x ()) / (float) (output.width ())) * animationProgress;
	    }

	    if (output.top () == 0)
	    {
		offsetInWorldY = ((vpSize.y () * sy) / ((float) output.height ()) * (offsetInScreenCoords.y ()) * animationProgress);
		worldScaleFactorY = 1.0f - ((float) (offsetInScreenCoords.y ()) / (float) output.height ()) * animationProgress;
	    }
	}
コード例 #9
0
void
MagScreen::preparePaint (int        time)
{
    if (adjust)
    {
	int   steps;
	float amount, chunk;

	amount = time * 0.35f * optionGetSpeed ();
	steps  = amount / (0.5f * optionGetTimestep ());

	if (!steps)
	    steps = 1;

	chunk  = amount / (float) steps;

	while (steps--)
	{
	    adjust = adjustZoom (chunk);
	    if (adjust)
		break;
	}
    }

    if (zoom != 1.0)
    {
	if (!poller.active ())
	{
	    CompPoint pos;
	    pos = poller.getCurrentPosition ();
	    posX = pos.x ();
	    posY = pos.y ();
	    poller.start ();
	}
	damageRegion ();
    }

    cScreen->preparePaint (time);
}
コード例 #10
0
CompPoint
compiz::window::extents::shift (const CompWindowExtents &extents,
				unsigned int            gravity)
{
    CompPoint rv = CompPoint ();

    switch (gravity) {
	case NorthGravity:
	case NorthWestGravity:
	case NorthEastGravity:
	    rv.setY (extents.top);
	    break;
	case SouthGravity:
	case SouthWestGravity:
	case SouthEastGravity:
	    rv.setY (-extents.bottom);
	    break;
	default:
	    break;
    }

    switch (gravity) {
	case WestGravity:
	case NorthWestGravity:
	case SouthWestGravity:
	    rv.setX (extents.left);
	    break;
	case EastGravity:
	case NorthEastGravity:
	case SouthEastGravity:
	    rv.setX (-extents.right);
	    break;
    }

    return rv;
}
コード例 #11
0
void GrabEdge::PerformWMAction(CompPoint const& p, unsigned button, Time timestamp)
{
  WMAction action = Style::Get()->WindowManagerAction(WMEvent(button));

  switch (action)
  {
    case WMAction::TOGGLE_SHADE:
      if (win_->state() & CompWindowStateShadedMask)
        win_->changeState(win_->state() & ~CompWindowStateShadedMask);
      else
        win_->changeState(win_->state() | CompWindowStateShadedMask);

      win_->updateAttributes(CompStackingUpdateModeNone);
      break;
    case WMAction::TOGGLE_MAXIMIZE:
      if ((win_->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
        win_->maximize(0);
      else
        win_->maximize(MAXIMIZE_STATE);
      break;
    case WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY:
      if (win_->state() & CompWindowStateMaximizedHorzMask)
        win_->maximize(0);
      else
        win_->maximize(CompWindowStateMaximizedHorzMask);
      break;
    case WMAction::TOGGLE_MAXIMIZE_VERTICALLY:
    if (win_->state() & CompWindowStateMaximizedVertMask)
        win_->maximize(0);
      else
        win_->maximize(CompWindowStateMaximizedVertMask);
      break;
    case WMAction::MINIMIZE:
      win_->minimize();
      break;
    case WMAction::SHADE:
      win_->changeState(win_->state() | CompWindowStateShadedMask);
      win_->updateAttributes(CompStackingUpdateModeNone);
      break;
    case WMAction::MENU:
      screen->toolkitAction(Atoms::toolkitActionWindowMenu, timestamp, win_->id(), button, p.x(), p.y());
      break;
    case WMAction::LOWER:
      win_->lower();
      break;
    default:
      break;
  }
}
コード例 #12
0
ファイル: paint.cpp プロジェクト: Jubei-Mitsuyoshi/aaa-compiz
/* This function currently always performs occlusion detection to
   minimize paint regions. OpenGL precision requirements are no good
   enough to guarantee that the results from using occlusion detection
   is the same as without. It's likely not possible to see any
   difference with most hardware but occlusion detection in the
   transformed screen case should be made optional for those who do
   see a difference. */
void
PrivateGLScreen::paintOutputRegion (const GLMatrix   &transform,
				    const CompRegion &region,
				    CompOutput       *output,
				    unsigned int     mask)
{
    CompRegion    tmpRegion (region);
    CompWindow    *w;
    GLWindow      *gw;
    int           windowMask, odMask;
    bool          status, unredirectFS;
    bool          withOffset = false;
    GLMatrix      vTransform;
    CompPoint     offXY;
    std::set<CompWindow*> unredirected;

    CompWindowList                   pl;
    CompWindowList::reverse_iterator rit;

    unredirectFS = CompositeScreen::get (screen)->
	getOption ("unredirect_fullscreen_windows")->value ().b ();

    const CompMatch &unredirectable = CompositeScreen::get (screen)->
	getOption ("unredirect_match")->value ().match ();

    const CompString &blacklist =
	getOption ("unredirect_driver_blacklist")->value ().s ();

    bool blacklisted = driverIsBlacklisted (blacklist.c_str ());

    if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
    {
	windowMask     = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
    }
    else
    {
	windowMask     = 0;
    }

    /*
     * We need to COPY the PaintList for now because there seem to be some
     * odd cases where the master list might change during the below loops.
     * (LP: #958540)
     */
    pl = cScreen->getWindowPaintList ();

    if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
    {
	FullscreenRegion fs (*output, screen->region ());

	/* detect occlusions */
	for (rit = pl.rbegin (); rit != pl.rend (); ++rit)
	{
	    w = (*rit);
	    gw = GLWindow::get (w);

	    if (w->destroyed ())
		continue;

	    if (!w->shaded ())
	    {
		/* Non-damaged windows don't have valid pixmap
		 * contents and we aren't displaying them yet
		 * so don't factor them into occlusion detection */
		if (!gw->priv->cWindow->damaged ())
		{
		    gw->priv->clip = region;
		    continue;
		}
		if (!w->isViewable ())
		    continue;
	    }

	    /* copy region */
	    gw->priv->clip = tmpRegion;

	    odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;

	    if ((cScreen->windowPaintOffset ().x () != 0 ||
		 cScreen->windowPaintOffset ().y () != 0) &&
		!w->onAllViewports ())
	    {
		withOffset = true;

		offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

		vTransform = transform;
		vTransform.translate (offXY.x (), offXY.y (), 0);

		gw->priv->clip.translate (-offXY.x (), -offXY. y ());

		odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
		status = gw->glPaint (gw->paintAttrib (), vTransform,
				      tmpRegion, odMask);
	    }
	    else
	    {
		withOffset = false;
		status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,
				      odMask);
	    }

	    if (status)
	    {
		if (withOffset)
		{
		    tmpRegion -= w->region ().translated (offXY);
		}
		else
		    tmpRegion -= w->region ();
	    }

	    FullscreenRegion::WinFlags flags = 0;
	    if (w->type () & CompWindowTypeDesktopMask)
	        flags |= FullscreenRegion::Desktop;
	    if (w->alpha ())
		flags |= FullscreenRegion::Alpha;
	    
	    /* Anything which was not occlusion detected is not a suitable
	     * candidate for unredirection either */
	    if (!status)
		flags |= FullscreenRegion::NoOcclusionDetection;

	    CompositeWindow *cw = CompositeWindow::get (w);

	    /*
	     * Windows with alpha channels can partially occlude windows
	     * beneath them and so neither should be unredirected in that case.
	     *
	     * Performance note:  unredirectable.evaluate is SLOW because it
	     * involves regex matching. Too slow to do on every window for
	     * every frame. So we only call it if a window is redirected AND
	     * potentially needs unredirecting. This means changes to
	     * unredirect_match while a window is unredirected already may not
	     * take effect until it is un-fullscreened again. But that's better
	     * than the high price of regex matching on every frame.
	     */
	    if (unredirectFS &&
		!blacklisted &&
		!(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
		!(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
		fs.isCoveredBy (w->region (), flags) &&
		(!cw->redirected () || unredirectable.evaluate (w)))
	    {
		unredirected.insert (w);
	    }
	    else
	    {
		if (!cw->redirected ())
		{
		    if (fs.allowRedirection (w->region ()))
		    {
			// 1. GLWindow::release to force gw->priv->needsRebind
			gw->release ();

			// 2. GLWindow::bind, which redirects the window,
			//    rebinds the pixmap, and then rebinds the pixmap
			//    to a texture.
			gw->bind ();

			// 3. Your window is now redirected again with the
			//    latest pixmap contents.
		    }
		    else
		    {
			unredirected.insert (w);
		    }
		}
	    }
	}
    }

    /* Unredirect any redirected fullscreen windows */
    foreach (CompWindow *fullscreenWindow, unredirected)
	CompositeWindow::get (fullscreenWindow)->unredirect ();

    if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
	paintBackground (transform,
	                 tmpRegion,
	                 (mask & PAINT_SCREEN_TRANSFORMED_MASK));

    /* paint all windows from bottom to top */
    foreach (w, pl)
    {
	if (w->destroyed ())
	    continue;

        gw = GLWindow::get (w);

        /* Release any queued ConfigureWindow requests now */
	gw->priv->configureLock->release ();

	if (unredirected.find (w) != unredirected.end ())
	    continue;

	if (!w->shaded ())
	{
	    if (!w->isViewable ())
		continue;
	}

	const CompRegion &clip =
	    (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
	    gw->clip () : region;

	if ((cScreen->windowPaintOffset ().x () != 0 ||
	     cScreen->windowPaintOffset ().y () != 0) &&
	    !w->onAllViewports ())
	{
	    offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

	    vTransform = transform;
	    vTransform.translate (offXY.x (), offXY.y (), 0);
	    gw->glPaint (gw->paintAttrib (), vTransform, clip,
		         windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
	}
	else
	{
	    gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);
	}
    }
}
コード例 #13
0
ファイル: region.cpp プロジェクト: squarehimself/XMoniz
void
CompRegion::shrink (const CompPoint &p)
{
    translate (p.x (), p.y ());
}
コード例 #14
0
ファイル: region.cpp プロジェクト: squarehimself/XMoniz
bool
CompRegion::contains (const CompPoint &p) const
{
    return XPointInRegion (handle (), p.x (), p.y ());
}