static char *
sessionGetClientLeaderProperty (CompWindow *w,
				Atom       atom)
{
    Window        clientLeader;

    clientLeader = w->clientLeader;

    /* try to find clientLeader on transient parents */
    if (!clientLeader)
    {
	CompWindow *window = w;

	while (window && window->transientFor)
	{
	    if (window->transientFor == window->id)
		break;

	    window = findWindowAtScreen (w->screen, window->transientFor);
	    if (window && window->clientLeader)
	    {
		clientLeader = window->clientLeader;
		break;
	    }
	}
    }

    if (!clientLeader)
	clientLeader = w->id;

    return sessionGetTextProperty (w->screen->display, clientLeader, atom);
}
Exemple #2
0
static void cloneSetStrutsForCloneWindow(CompScreen * s, CloneClone * clone)
{
	CompOutput *output = &s->outputDev[clone->dst];
	XRectangle *rect = NULL;
	CompStruts *struts;
	CompWindow *w;

	w = findWindowAtScreen(s, clone->input);
	if (!w)
		return;

	struts = malloc(sizeof(CompStruts));
	if (!struts)
		return;

	if (w->struts)
		free(w->struts);

	struts->left.x = 0;
	struts->left.y = 0;
	struts->left.width = 0;
	struts->left.height = s->height;

	struts->right.x = s->width;
	struts->right.y = 0;
	struts->right.width = 0;
	struts->right.height = s->height;

	struts->top.x = 0;
	struts->top.y = 0;
	struts->top.width = s->width;
	struts->top.height = 0;

	struts->bottom.x = 0;
	struts->bottom.y = s->height;
	struts->bottom.width = s->width;
	struts->bottom.height = 0;

	/* create struts relative to a screen edge that this output is next to */
	if (output->region.extents.x1 == 0)
		rect = &struts->left;
	else if (output->region.extents.x2 == s->width)
		rect = &struts->right;
	else if (output->region.extents.y1 == 0)
		rect = &struts->top;
	else if (output->region.extents.y2 == s->height)
		rect = &struts->bottom;

	if (rect) {
		rect->x = output->region.extents.x1;
		rect->y = output->region.extents.y1;
		rect->width = output->width;
		rect->height = output->height;
	}

	w->struts = struts;
}
Exemple #3
0
/* Resets the Window to the original opacity if it still exists.
 */
static void
resetOpacity (CompScreen *s,
              Window     id)
{
	CompWindow *w;

	w = findWindowAtScreen (s, id);
	if (!w)
		return;

	OPACIFY_WINDOW (w);

	ow->opacified = FALSE;

	addWindowDamage (w);
}
/*
 * After painting clean up
 */
static void
smartputDonePaintScreen (CompScreen *s)
{
    CompWindow *w = NULL;

    SMARTPUT_SCREEN (s);
    if(sps->lastWindow != None)
    {
        w = findWindowAtScreen (s,sps->lastWindow);
    }

    if (sps->animation && sps->grabIndex)
	damageScreen (s);
    else
    {
	if(w)
	{
	    SMARTPUT_WINDOW (w);
	    if(spw->mask && spw->xwc)
	    {
		if (w->mapNum && (spw->mask & (CWWidth | CWHeight)))
		{
		    sendSyncRequest (w);
		    configureXWindow (w, spw->mask, spw->xwc);
		}
		spw->mask = 0;
		free(spw->xwc);
		spw->xwc  = NULL;
	    }
	}
	if (sps->grabIndex)
	{
	    /* release the screen grab */
	    removeScreenGrab (s, sps->grabIndex, NULL);
	    sps->grabIndex = 0;
	}
    }

    UNWRAP (sps, s, donePaintScreen);
    (*s->donePaintScreen) (s);
    WRAP (sps, s, donePaintScreen, smartputDonePaintScreen);
}
CompWindow *
findWindowAtDisplay (CompDisplay *d,
		     Window      id)
{
    if (lastFoundWindow && lastFoundWindow->id == id)
    {
	return lastFoundWindow;
    }
    else
    {
	CompScreen *s;
	CompWindow *w;

	for (s = d->screens; s; s = s->next)
	{
	    w = findWindowAtScreen (s, id);
	    if (w)
		return w;
	}
    }

    return 0;
}
Exemple #6
0
/* Takes the inital event.
 * If we were configured, recalculate the opacify-windows if
 * it was our window.
 * If a window was entered: call upon handle_timeout after od->timeout
 * micro seconds, or directly if od->timeout is 0 (no delay).
 *
 */
static void
opacifyHandleEvent (XEvent      *event)
{
	CompScreen *s;

	OPACIFY_DISPLAY (&display);

	UNWRAP (od, &display, handleEvent);
	(display.handleEvent) (event);
	WRAP (od, &display, handleEvent, opacifyHandleEvent);

	switch (event->type) {
	case EnterNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xcrossing.root);

		if (s)
		{
			Window id;

			OPACIFY_SCREEN (s);

			id = event->xcrossing.window;
			os->newActive = findTopLevelWindowAtScreen (s, id);

			if (od->timeoutHandle)
				compRemoveTimeout (od->timeoutHandle);

			const BananaValue *
			option_timeout = bananaGetOption (bananaIndex,
			                                  "timeout",
			                                  -1);

			if (checkDelay (s))
				handleTimeout (s);
			else
				od->timeoutHandle = compAddTimeout (option_timeout->i,
				                                    (float)
				                                    option_timeout->i * 1.2,
				                                    handleTimeout, s);
		}
		break;
	case ConfigureNotify:
		if (!od->toggle)
			return;

		s = findScreenAtDisplay (event->xconfigure.event);
		if (s)
		{
			OPACIFY_SCREEN (s);

			if (os->active != event->xconfigure.window)
				break;

			clearPassive (s);
			if (os->active)
			{
				CompWindow *w;

				w = findWindowAtScreen (s, os->active);
				if (w)
					passiveWindows (s, w->region);
			}
		}
	case KeyPress:
		if (isKeyPressEvent (event, &od->toggle_key))
			opacifyToggle ();

		break;
	default:
		break;
	}
}
static void
swapToWindow (CompScreen *s,
	      Bool       toNext)
{
    CompWindow *w;
    int	       cur, nextIdx;

    SWAP_SCREEN (s);

    if (!ss->grabIndex)
	return;

    for (cur = 0; cur < ss->nWindows; cur++)
    {
	if (ss->windows[cur]->id == ss->selectedWindow)
	    break;
    }

    if (cur == ss->nWindows)
	return;

    if (toNext)
	nextIdx = (cur + 1) % ss->nWindows;
    else
	nextIdx = (cur + ss->nWindows - 1) % ss->nWindows;

    w = ss->windows[nextIdx];

    if (w)
    {
	Window old = ss->selectedWindow;

	if (ss->selection == AllViewports && swapGetAutoChangeVp (s))
	{
	    XEvent xev;
	    int	   x, y;

	    defaultViewportForWindow (w, &x, &y);

	    xev.xclient.type = ClientMessage;
	    xev.xclient.display = s->display->display;
	    xev.xclient.format = 32;

	    xev.xclient.message_type = s->display->desktopViewportAtom;
	    xev.xclient.window = s->root;

	    xev.xclient.data.l[0] = x * s->width;
	    xev.xclient.data.l[1] = y * s->height;
	    xev.xclient.data.l[2] = 0;
	    xev.xclient.data.l[3] = 0;
	    xev.xclient.data.l[4] = 0;

	    XSendEvent (s->display->display, s->root, FALSE,
			SubstructureRedirectMask | SubstructureNotifyMask,
			&xev);
	}

	ss->selectedWindow = w->id;

	if (old != w->id)
	{
	    ss->move = nextIdx;

	    ss->moreAdjust = 1;
	}

	if (ss->popupWindow)
	{
	    CompWindow *popup;

	    popup = findWindowAtScreen (s, ss->popupWindow);
	    if (popup)
		addWindowDamage (popup);

	    swapSetSelectedWindowHint (s);
	}

	swapDoWindowDamage (w);

	if (old)
	{
	    w = findWindowAtScreen (s, old);
	    if (w)
		swapDoWindowDamage (w);
	}
    }
}