static void
NEGScreenOptionChanged (CompScreen       *s,
			CompOption       *opt,
			NegScreenOptions num)
{
    switch (num)
    {
    case NegScreenOptionNegMatch:
    case NegScreenOptionExcludeMatch:
	{
	    CompWindow *w;
	    NEG_SCREEN (s);

	    for (w = s->windows; w; w = w->next)
	    {
		Bool isNeg;
		NEG_WINDOW (w);

		isNeg = matchEval (negGetNegMatch (s), w);
		isNeg = isNeg && !matchEval (negGetExcludeMatch (s), w);

		if (isNeg && ns->isNeg && !nw->isNeg)
		    NEGToggle (w);
		else if (!isNeg && nw->isNeg)
		    NEGToggle (w);
	    }
	}
	break;
    default:
	break;
    }
}
Exemplo n.º 2
0
Arquivo: fade.c Projeto: zmike/compiz
static Bool
fadeDamageWindowRect(CompWindow *w,
                     Bool initial,
                     BoxPtr rect)
{
   Bool status;

   FADE_SCREEN(w->screen);

   if (initial)
     {
        FADE_WINDOW(w);

        fw->fadeOut = FALSE;

        if (fw->shaded)
          {
             fw->shaded = w->shaded;
          }
        else if (matchEval(&fs->match, w))
          {
             if (isFadeWinForOpenClose(w))
               {
                  fw->opacity = 0;
                  fw->targetOpacity = 0;
               }
          }
     }

   UNWRAP(fs, w->screen, damageWindowRect);
   status = (*w->screen->damageWindowRect)(w, initial, rect);
   WRAP(fs, w->screen, damageWindowRect, fadeDamageWindowRect);

   return status;
}
static Bool
isRingWin (CompWindow *w)
{
    RING_SCREEN (w->screen);

    if (w->destroyed)
	return FALSE;

    if (w->attrib.override_redirect)
	return FALSE;

    if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
	return FALSE;

    if (!w->mapNum || w->attrib.map_state != IsViewable)
    {
	if (ringGetMinimized (w->screen))
	{
	    if (!w->minimized && !w->inShowDesktopMode && !w->shaded)
		return FALSE;
	}
	else
    	    return FALSE;
    }

    if (rs->type == RingTypeNormal)
    {
	if (!w->mapNum || w->attrib.map_state != IsViewable)
	{
	    if (w->serverX + w->width  <= 0    ||
		w->serverY + w->height <= 0    ||
		w->serverX >= w->screen->width ||
		w->serverY >= w->screen->height)
		return FALSE;
	}
	else
	{
	    if (!(*w->screen->focusWindow) (w))
		return FALSE;
	}
    }
    else if (rs->type == RingTypeGroup &&
	     rs->clientLeader != w->clientLeader &&
	     rs->clientLeader != w->id)
    {
	return FALSE;
    }

    if (w->state & CompWindowStateSkipTaskbarMask)
	return FALSE;

    if (!matchEval (rs->currentMatch, w))
	return FALSE;

    return TRUE;
}
/*
 * Filter windows when they are open if they match the filtering rules
 */
static void
colorFilterWindowAdd (CompScreen *s,
		      CompWindow *w)
{
    FILTER_SCREEN (s);

    /* cfw->isFiltered is initialized to FALSE in InitWindow, so we only
       have to toggle it to TRUE if necessary */
    if (cfs->isFiltered && matchEval (colorfilterGetFilterMatch (s), w))
	colorFilterToggleWindow (w);
}
Exemplo n.º 5
0
/* Check if we switched active window, reset the old passive windows
 * if we did. If we have an active window and switched: reset that too.
 * If we have a window (w is true), update the active id and
 * passive list. justMoved is to make sure we recalculate opacity after
 * moving. We can't reset before moving because if we're using a delay
 * and the window being moved is not the active but overlapping, it will
 * be reset, which would conflict with move's opacity change.
 */
static void
opacifyHandleEnter (CompScreen *s,
                    CompWindow *w)
{
	OPACIFY_SCREEN (s);

	if (otherScreenGrabExist (s, NULL))
	{
		if (!otherScreenGrabExist (s, "move", NULL))
		{
			os->justMoved = TRUE;
			return;
		}

		clearPassive (s);
		resetOpacity (s, os->active);
		os->active = 0;
		return;
	}

	if (!w || os->active != w->id || os->justMoved)
	{
		os->justMoved = FALSE;
		clearPassive (s);
		resetOpacity (s, os->active);
		os->active = 0;
	}

	if (!w)
		return;

	if (w->id != os->active && !w->shaded &&
	    matchEval (&os->window_match, w))
	{
		int num;

		os->active = w->id;
		num = passiveWindows (s, w->region);

		const BananaValue *
		option_only_if_block = bananaGetOption (bananaIndex,
		                                        "only_if_block",
		                                        s->screenNum);

		const BananaValue *
		option_active_opacity = bananaGetOption (bananaIndex,
		                                         "active_opacity",
		                                         s->screenNum);

		if (num || option_only_if_block->b)
			setOpacity (w, MAX (OPAQUE * option_active_opacity->i / 100,
			                    w->paint.opacity));
	}
}
static void
NEGWindowAdd (CompScreen *s,
	      CompWindow *w)
{
    NEG_SCREEN (s);

    /* nw->isNeg is initialized to FALSE in InitWindow, so we only
       have to toggle it to TRUE if necessary */
    if (ns->isNeg && matchEval (negGetNegMatch (s), w))
	NEGToggle (w);
}
Exemplo n.º 7
0
Arquivo: fade.c Projeto: zmike/compiz
/* Returns whether this window should be faded
 * on open and close events. */
static Bool
isFadeWinForOpenClose(CompWindow *w)
{
   FADE_DISPLAY(w->screen->display);
   FADE_SCREEN(w->screen);

   if (fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b &&
       !fd->suppressMinimizeOpenClose)
     {
        return TRUE;
     }
   return matchEval(&fd->alwaysFadeWindowMatch, w);
}
Exemplo n.º 8
0
/*
 * Filter windows when they are open if they match the filtering rules
 */
static void
colorFilterWindowAddNotify (CompWindow *w)
{
	FILTER_SCREEN (w->screen);

	/* cfw->isFiltered is initialized to FALSE in InitWindow, so we only
	   have to toggle it to TRUE if necessary */
	if (cfs->isFiltered && matchEval (&cfs->filter_match, w))
		colorFilterToggleWindow (w);

	UNWRAP (cfs, w->screen, windowAddNotify);
	(*w->screen->windowAddNotify) (w);
	WRAP (cfs, w->screen, windowAddNotify, colorFilterWindowAddNotify);
}
static void
NEGToggle (CompWindow *w)
{
    NEG_WINDOW (w);

    /* toggle window negative flag */
    nw->isNeg = !nw->isNeg;

    /* check exclude list */
    if (matchEval (negGetExcludeMatch (w->screen), w))
	nw->isNeg = FALSE;

    /* cause repainting */
    addWindowDamage (w);
}
/*
 * Toggle filtering for a specific window
 */
static void
colorFilterToggleWindow (CompWindow * w)
{
    FILTER_WINDOW (w);

    /* Toggle window filtering flag */
    cfw->isFiltered = !cfw->isFiltered;

    /* Check exclude list */
    if (matchEval (colorfilterGetExcludeMatch (w->screen), w))
	cfw->isFiltered = FALSE;

    /* Ensure window is going to be repainted */
    addWindowDamage (w);
}
Exemplo n.º 11
0
static Bool
winrulesMatchSize (CompWindow *w,
                   int        *width,
                   int        *height)
{
	CompScreen *s = w->screen;
	WINRULES_SCREEN (s);
	int i, min;

	if (!isWinrulesWindow (w))
		return FALSE;

	if (w->type & CompWindowTypeDesktopMask)
		return FALSE;

	const BananaValue *
	option_size_matches = bananaGetOption (bananaIndex,
	                                       "size_matches",
	                                       s->screenNum);

	const BananaValue *
	option_size_width_values = bananaGetOption (bananaIndex,
	                                            "size_width_values",
	                                            s->screenNum);

	const BananaValue *
	option_size_height_values = bananaGetOption (bananaIndex,
	                                             "size_height_values",
	                                             s->screenNum);

	min = MIN (option_size_matches->list.nItem,
	           option_size_width_values->list.nItem);

	min = MIN (min, option_size_height_values->list.nItem);

	for (i = 0; i < min; i++)
	{
		if (matchEval (&ws->size_matches[i], w))
		{
			*width = option_size_width_values->list.item[i].i;
			*height = option_size_height_values->list.item[i].i;

			return TRUE;
		}
	}

	return FALSE;
}
Exemplo n.º 12
0
static void
winrulesSetAllowedActions (CompWindow *w,
                           CompMatch  *match,
                           int        action)
{
	WINRULES_WINDOW (w);

	if (!isWinrulesWindow (w))
		return;

	if (matchEval (match, w))
		ww->allowedActions &= ~action;
	else if (!(ww->allowedActions & action))
		ww->allowedActions |= action;

	recalcWindowActions (w);
}
Exemplo n.º 13
0
static Bool
isSessionWindow (CompWindow *w)
{
    if (w->attrib.override_redirect)
	return FALSE;

    /* filter out embedded windows (notification icons) */
    if (sessionGetIsEmbedded (w->screen->display, w->id))
	return FALSE;

    SESSION_DISPLAY (w->screen->display);

    if (matchEval (&sd->opt[SESSION_DISPLAY_OPTION_IGNORE_MATCH].value.match, w))
	return FALSE;

    return TRUE;
}
static Bool
windowIs3D (CompWindow *w)
{
    if (w->attrib.override_redirect)
	return FALSE;

    if (!(w->shaded || w->attrib.map_state == IsViewable))
	return FALSE;

    if (w->state & (CompWindowStateSkipPagerMask |
		    CompWindowStateSkipTaskbarMask))
	return FALSE;
	
    if (!matchEval (tdGetWindowMatch (w->screen), w))
	return FALSE;

    return TRUE;
}
Exemplo n.º 15
0
static void
winrulesSetNoAlpha (CompWindow *w,
                    CompMatch  *match)
{
	WINRULES_WINDOW (w);

	if (!isWinrulesWindow (w))
		return;

	if (matchEval (match, w))
	{
		ww->hasAlpha = w->alpha;
		w->alpha = FALSE;
	}
	else
	{
		w->alpha = ww->hasAlpha;
	}
}
/*
 * Filtering match settings update callback
 */
static void
colorFilterMatchsChanged (CompScreen *s, CompOption *opt,
			  ColorfilterScreenOptions num)
{
    CompWindow *w;

    FILTER_SCREEN (s);

    /* Re-check every window against new match settings */
    for (w = s->windows; w; w = w->next)
    {
	FILTER_WINDOW (w);
	if (matchEval (colorfilterGetFilterMatch (s), w) &&
	    cfs->isFiltered && !cfw->isFiltered)
	{
	    colorFilterToggleWindow (w);
	}
    }
}
Exemplo n.º 17
0
/*
 * groupIsGroupWindow
 *
 */
Bool
groupIsGroupWindow (CompWindow *w)
{
	GROUP_SCREEN (w->screen);

	if (w->attrib.override_redirect)
		return FALSE;

	if (w->type & CompWindowTypeDesktopMask)
		return FALSE;

	if (w->invisible)
		return FALSE;

	if (!matchEval (&gs->window_match, w))
		return FALSE;

	return TRUE;
}
Exemplo n.º 18
0
Arquivo: 3d.c Projeto: jordigh/fusilli
static Bool
windowIs3D (CompWindow *w)
{
	TD_SCREEN (w->screen);

	if (w->attrib.override_redirect)
		return FALSE;

	if (!(w->shaded || w->attrib.map_state == IsViewable))
		return FALSE;

	if (w->state & (CompWindowStateSkipPagerMask |
	                CompWindowStateSkipTaskbarMask))
		return FALSE;

	if (!matchEval (&tds->window_match, w))
		return FALSE;

	return TRUE;
}
static Bool
isScaleWin (CompWindow *w)
{
    SCALE_SCREEN (w->screen);

    if (isNeverScaleWin (w))
	return FALSE;

    if (!ss->type || ss->type == ScaleTypeOutput)
    {
	if (!(*w->screen->focusWindow) (w))
	    return FALSE;
    }

    if (w->state & CompWindowStateSkipPagerMask)
	return FALSE;

    if (w->state & CompWindowStateShadedMask)
	return FALSE;

    if (!w->mapNum || w->attrib.map_state != IsViewable)
	return FALSE;

    switch (ss->type) {
    case ScaleTypeGroup:
	if (ss->clientLeader != w->clientLeader &&
	    ss->clientLeader != w->id)
	    return FALSE;
	break;
    case ScaleTypeOutput:
	if (outputDeviceForWindow(w) != w->screen->currentOutputDev)
	    return FALSE;
    default:
	break;
    }

    if (!matchEval (ss->currentMatch, w))
	return FALSE;

    return TRUE;
}
/* Heavily inspired by windowIs3D and isSDWindow,
   returns TRUE if the window is usable for tiling */
static Bool
isTileWindow (CompWindow *w)
{
    if (matchEval (tileGetExcludeMatch (w->screen->display), w))
	return FALSE;

    if (w->attrib.override_redirect)
	return FALSE;

    if (!((*w->screen->focusWindow) (w)))
	return FALSE;

    if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
	return FALSE;

    if (w->state & CompWindowStateSkipPagerMask)
	return FALSE;

    if (w->minimized || !w->placed)
	return FALSE;

    return TRUE;
}
Exemplo n.º 21
0
/* FIXME? Directly set inputHint, not a problem for now */
static void
winrulesSetNoFocus (CompWindow *w,
                    CompMatch  *match)
{
	unsigned int newProtocol = w->protocols;

	WINRULES_WINDOW (w);

	if (!isWinrulesWindow (w))
		return;

	if (matchEval (match, w))
	{
		if (w->protocols & CompWindowProtocolTakeFocusMask)
		{
			ww->protocolSetMask |= (w->protocols &
			                        CompWindowProtocolTakeFocusMask);
			newProtocol = w->protocols & ~CompWindowProtocolTakeFocusMask;
		}
		ww->oldInputHint = w->inputHint;
		w->inputHint = FALSE;
	}
	else if (ww->oldInputHint ||
	         (ww->protocolSetMask & CompWindowProtocolTakeFocusMask))
	{
		newProtocol = w->protocols |
		              (ww->protocolSetMask & CompWindowProtocolTakeFocusMask);
		ww->protocolSetMask &= ~CompWindowProtocolTakeFocusMask;
		w->inputHint = ww->oldInputHint;
	}

	if (newProtocol != w->protocols)
	{
		winrulesSetProtocols (newProtocol, w->id);
		w->protocols = newProtocol;
	}
}
Exemplo n.º 22
0
/* Walk through all windows, skip until we've passed the active
 * window, skip if it's invisible, hidden or minimized, skip if
 * it's not a window type we're looking for.
 * Dim it if it intersects.
 *
 * Returns number of changed windows.
 */
static int
passiveWindows (CompScreen *s,
                Region     region)
{
	CompWindow *w;
	Bool flag = FALSE;
	int i = 0;

	OPACIFY_SCREEN (s);

	for (w = s->windows; w; w = w->next)
	{
		if (w->id == os->active)
		{
			flag = TRUE;
			continue;
		}

		if (!flag)
			continue;

		if (!matchEval (&os->window_match, w))
			continue;

		if (w->invisible || w->hidden || w->minimized)
			continue;

		XIntersectRegion (w->region, region, os->intersect);
		if (!XEmptyRegion (os->intersect))
		{
			dimWindow (w);
			i++;
		}
	}

	return i;
}
Exemplo n.º 23
0
static void
winrulesUpdateState (CompWindow *w,
                     CompMatch  *match,
                     int        mask)
{
	unsigned int newState = w->state;

	WINRULES_WINDOW (w);

	if (!isWinrulesWindow (w))
		return;

	if (matchEval (match, w))
	{
		newState |= mask;
		newState = constrainWindowState (newState, w->actions);
		ww->stateSetMask |= (newState & mask);
	}
	else if (ww->stateSetMask & mask)
	{
		newState &= ~mask;
		ww->stateSetMask &= ~mask;
	}

	if (newState != w->state)
	{
		changeWindowState (w, newState);

		if (mask & (CompWindowStateFullscreenMask |
		            CompWindowStateAboveMask      |
		            CompWindowStateBelowMask       ))
			updateWindowAttributes (w, CompStackingUpdateModeNormal);
		else
			updateWindowAttributes (w, CompStackingUpdateModeNone);
	}
}
Exemplo n.º 24
0
Arquivo: fade.c Projeto: zmike/compiz
static void
fadeHandleEvent(CompDisplay *d,
                XEvent *event)
{
   CompWindow *w;

   FADE_DISPLAY(d);

   switch (event->type)
     {
      case DestroyNotify:
        w = findWindowAtDisplay(d, event->xdestroywindow.window);
        if (w)
          {
             FADE_SCREEN(w->screen);

             if (w->texture->pixmap && isFadeWinForOpenClose(w) &&
                 matchEval(&fs->match, w))
               {
                  FADE_WINDOW(w);

                  if (fw->opacity == 0xffff)
                    fw->opacity = 0xfffe;

                  fw->destroyCnt++;
                  w->destroyRefCnt++;

                  fw->fadeOut = TRUE;

                  addWindowDamage(w);
               }

             fadeRemoveDisplayModal(d, w);
          }
        break;

      case UnmapNotify:
        w = findWindowAtDisplay(d, event->xunmap.window);
        if (w)
          {
             FADE_SCREEN(w->screen);
             FADE_WINDOW(w);

             fw->shaded = w->shaded;

             if (fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b &&
                 !fd->suppressMinimizeOpenClose &&
                 !fw->shaded && w->texture->pixmap &&
                 matchEval(&fs->match, w))
               {
                  if (fw->opacity == 0xffff)
                    fw->opacity = 0xfffe;

                  fw->unmapCnt++;
                  w->unmapRefCnt++;

                  fw->fadeOut = TRUE;

                  addWindowDamage(w);
               }

             fadeRemoveDisplayModal(d, w);
          }
        break;

      case MapNotify:
        w = findWindowAtDisplay(d, event->xmap.window);
        if (w)
          {
             FADE_SCREEN(w->screen);

             if (fs->opt[FADE_SCREEN_OPTION_MINIMIZE_OPEN_CLOSE].value.b &&
                 !fd->suppressMinimizeOpenClose)
               {
                  fadeWindowStop(w);
               }
             if (w->state & CompWindowStateDisplayModalMask)
               fadeAddDisplayModal(d, w);
          }
        break;

      default:
        if (event->type == d->xkbEvent)
          {
             XkbAnyEvent *xkbEvent = (XkbAnyEvent *)event;

             if (xkbEvent->xkb_type == XkbBellNotify)
               {
                  XkbBellNotifyEvent *xkbBellEvent = (XkbBellNotifyEvent *)
                    xkbEvent;

                  w = findWindowAtDisplay(d, xkbBellEvent->window);
                  if (!w)
                    w = findWindowAtDisplay(d, d->activeWindow);

                  if (w)
                    {
                       CompScreen *s = w->screen;

                       FADE_SCREEN(s);

                       if (fs->opt[FADE_SCREEN_OPTION_VISUAL_BELL].value.b)
                         {
                            int option;

                            option = FADE_SCREEN_OPTION_FULLSCREEN_VISUAL_BELL;
                            if (fs->opt[option].value.b)
                              {
                                 for (w = s->windows; w; w = w->next)
                                   {
                                      if (w->destroyed)
                                        continue;

                                      if (w->attrib.map_state != IsViewable)
                                        continue;

                                      if (w->damaged)
                                        {
                                           FADE_WINDOW(w);

                                           fw->brightness = w->paint.brightness / 2;
                                        }
                                   }

                                 damageScreen(s);
                              }
                            else
                              {
                                 FADE_WINDOW(w);

                                 fw->brightness = w->paint.brightness / 2;

                                 addWindowDamage(w);
                              }
                         }
                    }
               }
          }
        break;
     }

   UNWRAP(fd, d, handleEvent);
   (*d->handleEvent)(d, event);
   WRAP(fd, d, handleEvent, fadeHandleEvent);

   switch (event->type)
     {
      case PropertyNotify:
        if (event->xproperty.atom == d->winStateAtom)
          {
             w = findWindowAtDisplay(d, event->xproperty.window);
             if (w && w->attrib.map_state == IsViewable)
               {
                  if (w->state & CompWindowStateDisplayModalMask)
                    fadeAddDisplayModal(d, w);
                  else
                    fadeRemoveDisplayModal(d, w);
               }
          }
        break;

      case ClientMessage:
        if (event->xclient.message_type == d->wmProtocolsAtom &&
            event->xclient.data.l[0] == d->wmPingAtom)
          {
             w = findWindowAtDisplay(d, event->xclient.data.l[2]);
             if (w)
               {
                  FADE_WINDOW(w);

                  if (w->alive != fw->alive)
                    {
                       addWindowDamage(w);
                       fw->alive = w->alive;
                    }
               }
          }
     }
}
Exemplo n.º 25
0
static Bool
minDamageWindowRect (CompWindow *w,
                     Bool       initial,
                     BoxPtr     rect)
{
	Bool status = FALSE;

	MIN_SCREEN (w->screen);
	MIN_WINDOW (w);

	if (mw->ignoreDamage)
		return TRUE;

	if (initial)
	{
		if (mw->state == IconicState)
		{
			mw->state = NormalState;

			if (!w->invisible      &&
			    w->iconGeometrySet &&
			    matchEval (&ms->match, w))
			{
				if (!mw->adjust)
				{
					mw->adjust     = TRUE;
					ms->moreAdjust = TRUE;

					mw->tx     = w->iconGeometry.x - w->serverX;
					mw->ty     = w->iconGeometry.y - w->serverY;
					mw->xScale = (float) w->iconGeometry.width  / w->width;
					mw->yScale = (float) w->iconGeometry.height / w->height;

					addWindowDamage (w);
				}
			}
		}
		else if (mw->region && mw->shade < w->height)
		{
			if (ms->shadeStep && !w->invisible)
			{
				XSubtractRegion (w->region, &emptyRegion, mw->region);
				XOffsetRegion (mw->region, -w->attrib.x, -w->attrib.y);

				/* bind pixmap here so we have something to unshade with */
				if (!w->texture->pixmap && !w->bindFailed)
					bindWindow (w);

				ms->moreAdjust = TRUE;
			}
			else
			{
				mw->shade = MAXSHORT;
			}
		}

		mw->newState = NormalState;
	}
	else if (mw->adjust)
	{
		damageTransformedWindowRect (w,
		                         mw->xScale,
		                         mw->yScale,
		                         mw->tx,
		                         mw->ty,
		                         rect);

		status = TRUE;
	}

	UNWRAP (ms, w->screen, damageWindowRect);
	status |= (*w->screen->damageWindowRect) (w, initial, rect);
	WRAP (ms, w->screen, damageWindowRect, minDamageWindowRect);

	return status;
}
Exemplo n.º 26
0
static void
minHandleEvent (XEvent      *event)
{
	CompWindow *w;

	MIN_DISPLAY (&display);

	switch (event->type) {
	case MapNotify:
		w = findWindowAtDisplay (event->xmap.window);
		if (w)
		{
			MIN_WINDOW (w);

			if (mw->adjust)
				mw->state = mw->newState;

			if (mw->region)
				w->height = 0;

			mw->ignoreDamage = TRUE;
			while (mw->unmapCnt)
			{
				unmapWindow (w);
				mw->unmapCnt--;
			}
			mw->ignoreDamage = FALSE;
		}
		break;
	case UnmapNotify:
		w = findWindowAtDisplay (event->xunmap.window);
		if (w)
		{
			MIN_SCREEN (w->screen);

			if (w->pendingUnmaps && onCurrentDesktop (w)) /* Normal -> Iconic */
			{
				MIN_WINDOW (w);

				if (w->shaded)
				{
					if (!mw->region)
						mw->region = XCreateRegion ();

					if (mw->region && ms->shadeStep)
					{
						XSubtractRegion (w->region, &emptyRegion, mw->region);
						XOffsetRegion (mw->region, -w->attrib.x,
						           w->attrib.height +
						           w->attrib.border_width * 2 -
						           w->height - w->attrib.y);

						mw->shade = w->height;

						mw->adjust     = FALSE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
				else if (!w->invisible && matchEval (&ms->match, w))
				{
					if (w->iconGeometrySet)
					{
						mw->newState = IconicState;

						mw->xScale = w->paint.xScale;
						mw->yScale = w->paint.yScale;
						mw->tx     = w->attrib.x - w->serverX;
						mw->ty     = w->attrib.y - w->serverY;

						if (mw->region)
						{
							XDestroyRegion (mw->region);
							mw->region = NULL;
						}

						mw->shade = MAXSHORT;

						mw->adjust     = TRUE;
						ms->moreAdjust = TRUE;

						mw->unmapCnt++;
						w->unmapRefCnt++;

						addWindowDamage (w);
					}
				}
			}
			else  /* X -> Withdrawn */
			{
				MIN_WINDOW (w);

				if (mw->adjust)
				{
					mw->adjust = FALSE;
					mw->xScale = mw->yScale = 1.0f;
					mw->tx = mw->ty = 0.0f;
					mw->xVelocity = mw->yVelocity = 0.0f;
					mw->xScaleVelocity = mw->yScaleVelocity = 1.0f;
					mw->shade = MAXSHORT;

					if (mw->region)
					{
						XDestroyRegion (mw->region);
						mw->region = NULL;
					}
				}

				mw->state = NormalState;
			}
		}
	default:
		break;
	}

	UNWRAP (md, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (md, &display, handleEvent, minHandleEvent);

	switch (event->type) {
	case MapRequest:
		w = findWindowAtDisplay (event->xmaprequest.window);
		if (w && w->hints && w->hints->initial_state == IconicState)
		{
			MIN_WINDOW (w);
			mw->newState = mw->state = IconicState;
		}
		break;
	default:
		break;
	}
}
Exemplo n.º 27
0
Bool
groupDamageWindowRect (CompWindow *w,
                       Bool       initial,
                       BoxPtr     rect)
{
	Bool status;
	CompScreen *s = w->screen;

	GROUP_SCREEN (s);
	GROUP_WINDOW (w);

	UNWRAP (gs, s, damageWindowRect);
	status = (*s->damageWindowRect)(w, initial, rect);
	WRAP (gs, s, damageWindowRect, groupDamageWindowRect);

	if (initial)
	{
		const BananaValue *
		option_autotab_create = bananaGetOption (bananaIndex,
		                                         "autotab_create",
		                                         s->screenNum);

		if (option_autotab_create->b && groupIsGroupWindow (w))
		{
			if (!gw->group && (gw->windowState == WindowNormal))
			{
				/* First check if this window should be added to an
				 * existing group */
				GroupSelection *g = NULL;
				int i;
				for (i = 0; i <= gs->autotabCount - 1; i++)
				{
					if (matchEval (&gs->autotab[i], w))
					{
						Bool foundGroup = FALSE;
						GroupSelection *tg;

						for (tg = gs->groups; tg; tg = tg->next)
						{
							int i;
							for (i = 0; i <= tg->nWins - 1; i++)
							{
								if (matchEval (&gs->autotab[i], tg->windows[i]))
								{
									foundGroup = TRUE;
									g = tg;
									break;
								}
							}

							if (foundGroup)
								break;
						}

						if (foundGroup)
							break;
					}
				}

				if (g)
				{
					groupAddWindowToGroup (w, g, 0);
					//groupTabGroup (w);
				}
				else
				{
					groupAddWindowToGroup (w, NULL, 0);
					//groupTabGroup (w);
				}
			}
		}

		if (gw->group)
		{
			if (gw->windowState == WindowMinimized)
			{
				const BananaValue *
				option_minimize_all = bananaGetOption (bananaIndex,
				                                       "minimize_all",
				                                       s->screenNum);

				if (option_minimize_all->b)
					groupMinimizeWindows (w, gw->group, FALSE);
			}
			else if (gw->windowState == WindowShaded)
			{
				const BananaValue *
				option_shade_all = bananaGetOption (bananaIndex,
				                                    "shade_all",
				                                    s->screenNum);

				if (option_shade_all->b)
					groupShadeWindows (w, gw->group, FALSE);
			}
		}

		gw->windowState = WindowNormal;
	}

	if (gw->resizeGeometry)
	{
		BoxRec box;

		groupGetStretchRectangle (w, &box, NULL, NULL);
		groupDamagePaintRectangle (s, &box);
	}

	if (gw->slot)
	{
		int vx, vy;
		Region reg;

		groupGetDrawOffsetForSlot (gw->slot, &vx, &vy);
		if (vx || vy)
		{
			reg = XCreateRegion ();
			XUnionRegion (reg, gw->slot->region, reg);
			XOffsetRegion (reg, vx, vy);
		}
		else
			reg = gw->slot->region;

		damageScreenRegion (s, reg);

		if (vx || vy)
			XDestroyRegion (reg);
	}

	return status;
}
Exemplo n.º 28
0
static void
colorFilterChangeNotify (const char        *optionName,
                         BananaType        optionType,
                         const BananaValue *optionValue,
                         int               screenNum)
{
	FILTER_DISPLAY (&display);

	if (strcasecmp (optionName, "toggle_window_key") == 0)
		updateKey (optionValue->s, &cfd->toggle_window_key);

	else if (strcasecmp (optionName, "toggle_screen_key") == 0)
		updateKey (optionValue->s, &cfd->toggle_screen_key);

	else if (strcasecmp (optionName, "switch_filter_key") == 0)
		updateKey (optionValue->s, &cfd->switch_filter_key);

	else if (strcasecmp (optionName, "filter_match") == 0)
	{
		CompWindow *w;
		CompScreen *s = getScreenFromScreenNum (screenNum);

		FILTER_SCREEN (s);

		//Re-check every window against new match settings
		for (w = s->windows; w; w = w->next)
		{
			FILTER_WINDOW (w);

			if (matchEval (&cfs->filter_match, w) &&
			    cfs->isFiltered && !cfw->isFiltered)
			{
				colorFilterToggleWindow (w);
			}
		}
	}

	else if (strcasecmp (optionName, "exclude_match") == 0)
	{
		CompWindow *w;
		CompScreen *s = getScreenFromScreenNum (screenNum);

		FILTER_SCREEN (s);

		// Re-check every window against new match settings
		for (w = s->windows; w; w = w->next)
		{
			Bool isExcluded;

			FILTER_WINDOW (w);

			isExcluded = matchEval (&cfs->exclude_match, w);

			if (isExcluded && cfw->isFiltered)
				colorFilterToggleWindow (w);
			else if (!isExcluded && cfs->isFiltered && !cfw->isFiltered)
				colorFilterToggleWindow (w);
		}
	}

	else if (strcasecmp (optionName, "filters") == 0)
	{
		CompScreen *s = getScreenFromScreenNum (screenNum);

		FILTER_SCREEN (s);

		/* Just set the filtersLoaded boolean to FALSE, unloadFilters will be
		 * called in loadFilters */

		cfs->filtersLoaded = FALSE;
	}

	else if (strcasecmp (optionName, "filter_decorations") == 0)
	{
		CompScreen *s = getScreenFromScreenNum (screenNum);

		damageScreen (s);
	}
}
Exemplo n.º 29
0
static Bool
decorWindowUpdate (CompWindow *w,
		   Bool	      allowDecoration)
{
    WindowDecoration *wd;
    Decoration	     *old, *decor = NULL;
    Bool	     decorate = FALSE;
    CompMatch	     *match;
    int		     moveDx, moveDy;
    int		     oldShiftX = 0;
    int		     oldShiftY  = 0;

    DECOR_DISPLAY (w->screen->display);
    DECOR_SCREEN (w->screen);
    DECOR_WINDOW (w);

    wd = dw->wd;
    old = (wd) ? wd->decor : NULL;

    switch (w->type) {
    case CompWindowTypeDialogMask:
    case CompWindowTypeModalDialogMask:
    case CompWindowTypeUtilMask:
    case CompWindowTypeMenuMask:
    case CompWindowTypeNormalMask:
	if (w->mwmDecor & (MwmDecorAll | MwmDecorTitle))
	    decorate = TRUE;
    default:
	break;
    }

    if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
	decorate = FALSE;

    if (w->attrib.override_redirect)
	decorate = FALSE;

    if (decorate)
    {
	match = &dd->opt[DECOR_DISPLAY_OPTION_DECOR_MATCH].value.match;
	if (!matchEval (match, w))
	    decorate = FALSE;
    }

    if (decorate)
    {
	if (dw->decor && decorCheckSize (w, dw->decor))
	{
	    decor = dw->decor;
	}
	else
	{
	    if (w->id == w->screen->display->activeWindow)
		decor = ds->decor[DECOR_ACTIVE];
	    else
		decor = ds->decor[DECOR_NORMAL];
	}
    }
    else
    {
	match = &dd->opt[DECOR_DISPLAY_OPTION_SHADOW_MATCH].value.match;
	if (matchEval (match, w))
	{
	    if (w->region->numRects == 1)
		decor = ds->decor[DECOR_BARE];

	    if (decor)
	    {
		if (!decorCheckSize (w, decor))
		    decor = NULL;
	    }
	}
    }

    if (!ds->dmWin || !allowDecoration)
	decor = NULL;

    if (decor == old)
	return FALSE;

    damageWindowOutputExtents (w);

    if (old)
    {
	oldShiftX = decorWindowShiftX (w);
	oldShiftY = decorWindowShiftY (w);

	destroyWindowDecoration (w->screen, wd);
    }

    if (decor)
    {
	dw->wd = createWindowDecoration (decor);
	if (!dw->wd)
	    return FALSE;

	if ((w->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
	    setWindowFrameExtents (w, &decor->maxInput);
	else
	    setWindowFrameExtents (w, &decor->input);

	moveDx = decorWindowShiftX (w) - oldShiftX;
	moveDy = decorWindowShiftY (w) - oldShiftY;

	updateWindowOutputExtents (w);
	damageWindowOutputExtents (w);
	updateWindowDecorationScale (w);
    }
    else
    {
	CompWindowExtents emptyInput;

	memset (&emptyInput, 0, sizeof (emptyInput));
	setWindowFrameExtents (w, &emptyInput);

	dw->wd = NULL;

	moveDx = -oldShiftX;
	moveDy = -oldShiftY;
    }

    if (w->placed && !w->attrib.override_redirect && (moveDx || moveDy))
    {
	XWindowChanges xwc;
	unsigned int   mask = CWX | CWY;

	xwc.x = w->serverX + moveDx;
	xwc.y = w->serverY + moveDy;

	if (w->state & CompWindowStateFullscreenMask)
	    mask &= ~(CWX | CWY);

	if (w->state & CompWindowStateMaximizedHorzMask)
	    mask &= ~CWX;

	if (w->state & CompWindowStateMaximizedVertMask)
	    mask &= ~CWY;

	if (w->saveMask & CWX)
	    w->saveWc.x += moveDx;

	if (w->saveMask & CWY)
	    w->saveWc.y += moveDy;

	if (mask)
	    configureXWindow (w, mask, &xwc);
    }

    return TRUE;
}
Exemplo n.º 30
0
static Bool
isSwapWin (CompWindow *w)
{
    CompScreen *s = w->screen;

    SWAP_SCREEN (s);

    if (!w->mapNum || w->attrib.map_state != IsViewable)
    {
	if (swapGetMinimized (s))
	{
	    if (!w->minimized && !w->inShowDesktopMode && !w->shaded)
		return FALSE;
	}
	else
	{
	    return FALSE;
	}
    }

    if (!(w->inputHint || (w->protocols & CompWindowProtocolTakeFocusMask)))
	return FALSE;

    if (w->attrib.override_redirect)
	return FALSE;

    if (ss->selection == Panels)
    {
	if (!(w->type & (CompWindowTypeDockMask | CompWindowTypeDesktopMask)))
	    return FALSE;
    }
    else
    {
	if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
	    return FALSE;

	if (w->state & CompWindowStateSkipTaskbarMask)
	    return FALSE;

	if (!matchEval (swapGetWindowMatch (s), w))
	    return FALSE;
    }

    if (ss->selection == CurrentViewport)
    {
	if (!w->mapNum || w->attrib.map_state != IsViewable)
	{
	    if (w->serverX + w->width  <= 0    ||
		w->serverY + w->height <= 0    ||
		w->serverX >= w->screen->width ||
		w->serverY >= w->screen->height)
		return FALSE;
	}
	else
	{
	    if (!(*w->screen->focusWindow) (w))
		return FALSE;
	}
    }
    else if (ss->selection == Group)
    {
	if (ss->clientLeader != w->clientLeader &&
	    ss->clientLeader != w->id)
	    return FALSE;
    }

    return TRUE;
}