static void
scaleaddonCheckWindowHighlight (CompScreen *s)
{
    CompDisplay *d = s->display;

    ADDON_DISPLAY (d);

    if (ad->highlightedWindow != ad->lastHighlightedWindow)
    {
        CompWindow *w;

        w = findWindowAtDisplay (d, ad->highlightedWindow);
        if (w)
        {
            scaleaddonRenderWindowTitle (w);
            addWindowDamage (w);
        }

        w = findWindowAtDisplay (d, ad->lastHighlightedWindow);
        if (w)
        {
            scaleaddonRenderWindowTitle (w);
            addWindowDamage (w);
        }

        ad->lastHighlightedWindow = ad->highlightedWindow;
    }
}
static void
titleinfoHandleEvent (CompDisplay *d,
		      XEvent      *event)
{
    TITLEINFO_DISPLAY (d);

    UNWRAP (td, d, handleEvent);
    (*d->handleEvent) (d, event);
    WRAP (td, d, handleEvent, titleinfoHandleEvent);

    if (event->type == PropertyNotify)
    {
	CompWindow *w;

	if (event->xproperty.atom == XA_WM_CLIENT_MACHINE)
	{
	    w = findWindowAtDisplay (d, event->xproperty.window);
	    if (w)
		titleinfoUpdateMachine (w);
	}
	else if (event->xproperty.atom == td->wmPidAtom)
	{
	    w = findWindowAtDisplay (d, event->xproperty.window);
	    if (w)
		titleinfoUpdatePid (w);
	}
	else if (event->xproperty.atom == d->wmNameAtom ||
		 event->xproperty.atom == XA_WM_NAME)
	{
	    w = findWindowAtDisplay (d, event->xproperty.window);
	    if (w)
		titleinfoUpdateTitle (w);
	}
    }
}
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_WINDOW (w);

	    if (!fw->direction)
		fw->opacity = OPAQUE - 1;

	    fw->direction = -1;
	    fw->destroyed = 1;

	    addWindowDamage (w);
	    return;
	}
	break;
    case UnmapNotify:
	w = findWindowAtDisplay (d, event->xunmap.window);
	if (w)
	{
	    FADE_WINDOW (w);

	    if (!fw->direction)
		fw->opacity = OPAQUE - 1;

	    fw->direction = -1;

	    addWindowDamage (w);
	    return;
	}
	break;
    case MapNotify:
	w = findWindowAtDisplay (d, event->xunmap.window);
	if (w)
	{
	    FADE_WINDOW (w);

	    /* make sure any pending unmap are processed */
	    if (fw->direction < 0)
		unmapWindow (w);
	}
    default:
	break;
    }

    UNWRAP (fd, d, handleEvent);
    (*d->handleEvent) (d, event);
    WRAP (fd, d, handleEvent, fadeHandleEvent);
}
/*
 * Initially triggered keybinding.
 * Fetch the every window and toggles its decoration.
 */
static Bool
toggledecoAllTrigger(CompDisplay     *d,
		     CompAction      *action,
		     CompActionState state,
		     CompOption      *option,
		     int             nOption)
{
    Window     xid;
    CompWindow *w;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    w   = findWindowAtDisplay (d, xid);
    if (w)
    {
	CompScreen *s = w->screen;
	CompWindow *window;
	for (window = s->windows; window; window = window->next)
	{
	    if(!toggledecoSameViewport (window,w)) continue;
	       window->mwmDecor = window->mwmDecor ^ MwmDecorAll;
	       (*window->screen->windowStateChangeNotify) (window, window->state);
	}
    }

    return TRUE;
}
Exemple #5
0
static Bool
waterTitleWave(CompDisplay * d,
	       CompAction * action,
	       CompActionState state, CompOption * option, int nOption)
{
	CompWindow *w;
	int xid;

	xid = getIntOptionNamed(option, nOption, "window", d->activeWindow);

	w = findWindowAtDisplay(d, xid);
	if (w) {
		XPoint p[2];

		p[0].x = w->attrib.x - w->input.left;
		p[0].y = w->attrib.y - w->input.top / 2;

		p[1].x = w->attrib.x + w->width + w->input.right;
		p[1].y = p[0].y;

		waterVertices(w->screen, GL_LINES, p, 2, 0.15f);

		damageScreen(w->screen);
	}

	return FALSE;
}
Exemple #6
0
/*
 * groupChangeColor
 *
 */
Bool
groupChangeColor (Window xid)
{
	CompWindow *w;

	w   = findWindowAtDisplay (xid);
	if (w)
	{
		GROUP_WINDOW (w);

		if (gw->group)
		{
			GLushort *color = gw->group->color;
			float factor = ((float)RAND_MAX + 1) / 0xffff;

			color[0] = (int)(rand () / factor);
			color[1] = (int)(rand () / factor);
			color[2] = (int)(rand () / factor);

			groupRenderTopTabHighlight (gw->group);
			damageScreen (w->screen);
		}
	}

	return FALSE;
}
/*
 * Initially triggered keybinding.
 * Fetch the window, fetch the resize, constrain it.
 *
 */
static Bool
smartputTrigger (CompDisplay     *d,
		 CompAction      *action,
		 CompActionState state,
		 CompOption      *option,
		 int             nOption)
{
    Window     xid;
    CompWindow *w;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    if(!xid)
	xid = d->activeWindow;

    w   = findWindowAtDisplay (d, xid);

    if (w)
    {
	if (w->invisible || w->hidden || w->minimized)
	    return FALSE;

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

	if (w->wmType & CompWindowTypeDockMask)
	    return FALSE;
	return smartputInitiate (w, action, state,
				 option, nOption,FALSE);

    }
    return FALSE;
}
static Bool
scaleaddonCloseWindow(CompDisplay * d,
		      CompAction * action,
		      CompActionState state, CompOption * option, int nOption)
{
	CompScreen *s;
	Window xid;

	xid = getIntOptionNamed(option, nOption, "root", 0);

	s = findScreenAtDisplay(d, xid);
	if (s) {
		CompWindow *w;

		SCALE_SCREEN(s);
		ADDON_DISPLAY(d);

		if (!ss->grabIndex)
			return FALSE;

		w = findWindowAtDisplay(d, ad->highlightedWindow);
		if (w) {
			closeWindow(w, getCurrentTimeFromDisplay(d));
			return TRUE;
		}
	}

	return FALSE;
}
static Bool
ringDoSwitch (CompDisplay     *d,
	      CompAction      *action,
	      CompActionState state,
	      CompOption      *option,
	      int             nOption,
	      Bool            nextWindow,
	      RingType        type)
{
    CompScreen *s;
    Window     xid;
    Bool       ret = TRUE;

    xid = getIntOptionNamed (option, nOption, "root", 0);

    s = findScreenAtDisplay (d, xid);
    if (s)
    {
	RING_SCREEN (s);

	if ((rs->state == RingStateNone) || (rs->state == RingStateIn))
	{
	    if (type == RingTypeGroup)
	    {
    		CompWindow *w;
    		w = findWindowAtDisplay (d, getIntOptionNamed (option, nOption,
    							       "window", 0));
    		if (w)
    		{
    		    rs->type = RingTypeGroup;
    		    rs->clientLeader = 
			(w->clientLeader) ? w->clientLeader : w->id;
		    ret = ringInitiate (s, action, state, option, nOption);
		}
	    }
	    else
	    {
		rs->type = type;
		ret = ringInitiate (s, action, state, option, nOption);
	    }

	    if (state & CompActionStateInitKey)
		action->state |= CompActionStateTermKey;

	    if (state & CompActionStateInitEdge)
		action->state |= CompActionStateTermEdge;
	    else if (state & CompActionStateInitButton)
		action->state |= CompActionStateTermButton;
	}

	if (ret)
    	    switchToWindow (s, nextWindow);
    }

    return ret;
}
static void
scaleaddonHandleEvent (CompDisplay *d,
                       XEvent      *event)
{
    ADDON_DISPLAY (d);

    UNWRAP (ad, d, handleEvent);
    (*d->handleEvent) (d, event);
    WRAP (ad, d, handleEvent, scaleaddonHandleEvent);

    switch (event->type)
    {
    case PropertyNotify:
    {
        if (event->xproperty.atom == XA_WM_NAME)
        {
            CompWindow *w;

            w = findWindowAtDisplay (d, event->xproperty.window);
            if (w)
            {
                SCALE_SCREEN (w->screen);
                if (ss->grabIndex)
                {
                    scaleaddonRenderWindowTitle (w);
                    addWindowDamage (w);
                }
            }
        }
    }
    break;
    case MotionNotify:
    {
        CompScreen *s;
        s = findScreenAtDisplay (d, event->xmotion.root);

        if (s)
        {
            SCALE_SCREEN (s);
            if (ss->grabIndex)
            {
                SCALE_DISPLAY (d);

                ad->highlightedWindow = sd->hoveredWindow;
                scaleaddonCheckWindowHighlight (s);
            }
        }
    }
    break;
    default:
        break;
    }
}
Exemple #11
0
static Bool
moveInitiate(CompDisplay    *d,
             CompAction     *action,
             CompActionState state,
             CompOption     *option,
             int             nOption)
{
   CompWindow *w;
   Window xid;
   int i, x, y;
   unsigned int ui;
   unsigned int mods = 0;

   MOVE_DISPLAY (d);
   xid = getIntOptionNamed (option, nOption, "window", 0);

   w = findWindowAtDisplay (d, xid);
   if (!w) return FALSE;

   if (otherScreenGrabExist (w->screen, "move", 0))
     return FALSE;

   MOVE_SCREEN (w->screen);

   XQueryPointer (d->display, w->screen->root,
                  &xid, &xid, &x, &y, &i, &i, &ui);

   if (md->w)
     return FALSE;

   lastPointerX = x;
   lastPointerY = y;

   ms->origState = w->state;

   if (!ms->grabIndex)
     ms->grabIndex = pushScreenGrab (w->screen, 0, "move");

   if (ms->grabIndex)
     {
        md->w = w;

        (w->screen->windowGrabNotify)(w, x, y, mods,
                                      CompWindowGrabMoveMask |
                                      CompWindowGrabButtonMask);

        if (md->moveOpacity != OPAQUE)
          addWindowDamage (w);
     }

   return FALSE;
}
static CompTextData *
textRenderWindowTitle (CompScreen           *s,
		       Window               window,
		       Bool                 withViewportNumber,
		       const CompTextAttrib *attrib)
{
    char         *text = NULL;
    CompTextData *retval;

    if (withViewportNumber)
    {
	char *title;
	
	title = textGetWindowName (s->display, window);
	if (title)
	{
	    CompWindow *w;

	    w = findWindowAtDisplay (s->display, window);
	    if (w)
	    {
		int vx, vy, viewport;

		defaultViewportForWindow (w, &vx, &vy);
		viewport = vy * w->screen->hsize + vx + 1;
		if (asprintf (&text, "%s -[%d]-", title, viewport) == -1)
		{
			free (title);
			return textRenderText (s, "Error: textRenderWindowTitle", attrib);
		}
		free (title);
	    }
	    else
	    {
		text = title;
	    }
	}
    }
    else
    {
	text = textGetWindowName (s->display, window);
    }

    retval = textRenderText (s, text, attrib);

    if (text)
	free (text);

    return retval;
}
Exemple #13
0
/*
 * groupRemoveWindow
 *
 */
Bool
groupRemoveWindow (Window xid)
{
	CompWindow *w;

	w   = findWindowAtDisplay (xid);
	if (w)
	{
		GROUP_WINDOW (w);

		if (gw->group)
			groupRemoveWindowFromGroup (w);
	}

	return FALSE;
}
/*
 * Window filtering toggle action
 */
static Bool
colorFilterToggle (CompDisplay * d, CompAction * action,
		   CompActionState state, CompOption * option, int nOption)
{
    CompWindow *w;
    Window xid;

    xid = getIntOptionNamed (option, nOption, "window", 0);

    w = findWindowAtDisplay (d, xid);

    if (w && w->screen->fragmentProgram)
	colorFilterToggleWindow (w);

    return TRUE;
}
static Bool
negToggle (CompDisplay     *d,
	   CompAction      *action,
	   CompActionState state,
 	   CompOption      *option,
	   int             nOption)
{
    CompWindow *w;
    Window     xid;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    w = findWindowAtDisplay (d, xid);

    if (w)
	NEGToggle (w);

    return TRUE;
}
static Bool
gridCommon (CompDisplay	    *d,
            CompAction	    *action,
            CompActionState state,
            CompOption	    *option,
            int		    nOption,
            GridType	    where)
{
    Window     xid;
    CompWindow *cw;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    cw  = findWindowAtDisplay (d, xid);

    gridCommonWindow(cw, where);

    return TRUE;
}
/*
 * Initially triggered keybinding.
 * Fetch the window and toggles its decoration.
 */
static Bool
toggledecoTrigger(CompDisplay     *d,
		  CompAction      *action,
		  CompActionState state,
		  CompOption      *option,
		  int             nOption)
{
    Window     xid;
    CompWindow *w;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    w   = findWindowAtDisplay (d, xid);
    if (w)
    {
	w->mwmDecor = w->mwmDecor ^ MwmDecorAll;
	(*w->screen->windowStateChangeNotify) (w, w->state);
    }

    return TRUE;
}
Exemple #18
0
/*
 * groupCloseWindows
 *
 */
Bool
groupCloseWindows (Window xid)
{
	CompWindow *w;

	w   = findWindowAtDisplay (xid);
	if (w)
	{
		GROUP_WINDOW (w);

		if (gw->group)
		{
			int i;

			for (i = 0; i < gw->group->nWins; i++)
				closeWindow (gw->group->windows[i],
				             getCurrentTimeFromDisplay ());
		}
	}

	return FALSE;
}
static void
sessionHandleEvent (CompDisplay *d,
		    XEvent      *event)
{
    CompWindow   *w;
    unsigned int state;

    SESSION_DISPLAY (d);

    w = NULL;
    state = 0;

    switch (event->type) {
    case MapRequest:
	w = findWindowAtDisplay (d, event->xmaprequest.window);
	if (w)
	{
	    state = w->state;
	    if (!sessionReadWindow (w))
		w = NULL;
	}
	break;
    }

    UNWRAP (sd, d, handleEvent);
    (*d->handleEvent) (d, event);
    WRAP (sd, d, handleEvent, sessionHandleEvent);

    switch (event->type) {
    case MapRequest:
	if (w && !(state & CompWindowStateDemandsAttentionMask))
	{
	    state = w->state & ~CompWindowStateDemandsAttentionMask;
	    changeWindowState (w, state);
	}
	break;
    }
}
Exemple #20
0
static void
winrulesHandleEvent (XEvent      *event)
{
	CompWindow *w;

	WINRULES_DISPLAY (&display);

	if (event->type == MapRequest)
	{
		w = findWindowAtDisplay (event->xmap.window);
		if (w)
		{
			WINRULES_SCREEN (w->screen);

			winrulesSetNoFocus (w, &ws->no_focus_match);
			winrulesApplyRules (w);
		}
	}

	UNWRAP (wd, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (wd, &display, handleEvent, winrulesHandleEvent);
}
Exemple #21
0
static void
colorFilterHandleEvent (XEvent      *event)
{
	FILTER_DISPLAY (&display);

	switch (event->type) {
	case KeyPress:
		if (isKeyPressEvent (event, &cfd->toggle_window_key))
		{
			CompWindow *w = findWindowAtDisplay (display.activeWindow);

			if (w && w->screen->fragmentProgram)
				colorFilterToggleWindow (w);
		}
		else if (isKeyPressEvent (event, &cfd->toggle_screen_key))
		{
			CompScreen *s = findScreenAtDisplay (event->xkey.root);

			if (s && s->fragmentProgram)
				colorFilterToggleScreen (s);
		}
		else if (isKeyPressEvent (event, &cfd->switch_filter_key))
		{
			CompScreen *s = findScreenAtDisplay (event->xkey.root);

			if (s && s->fragmentProgram)
				colorFilterSwitchFilter (s);
		}
		break;
	default:
		break;
	}

	UNWRAP (cfd, &display, handleEvent);
	(*display.handleEvent) (event);
	WRAP (cfd, &display, handleEvent, colorFilterHandleEvent);
}
/*
 * Tries to undo Smart Put last action
 */
static Bool
smartputUndo (CompDisplay     *d,
	      CompAction      *action,
	      CompActionState state,
	      CompOption      *option,
	      int             nOption)
{
    Window     xid;
    CompWindow *w;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    if(!xid)
	xid = d->activeWindow;

    w   = findWindowAtDisplay (d, xid);

    if (w)
    {
	return smartputInitiate (w, action, state,
				 option, nOption,TRUE);

    }
    return FALSE;
}
/*
 * Buggy
 */
static Bool
smartputAllTrigger (CompDisplay     *d,
		    CompAction      *action,
		    CompActionState state,
		    CompOption      *option,
		    int             nOption)
{
    Window     xid;
    CompWindow *w;
    CompScreen *s;
    int grabIndex = 0;

    xid = getIntOptionNamed (option, nOption, "window", 0);
    w   = findWindowAtDisplay (d, xid);
    if (w)
    {
	s = w->screen;

	if(otherScreenGrabExist (s, "smartput", 0))
	    return FALSE;

	/*
	 * Grab the screen
	 */

	grabIndex = pushScreenGrab (s, s->invisibleCursor, "smartput");

	if(!grabIndex)
	    return FALSE;

	CompWindow *window;
	for (window = s->windows; window; window = window->next)
	{
	    if(!smartputSameViewport (window,w) )
	       continue;
	    int            width, height;
	    unsigned int   mask;
	    XWindowChanges xwc;

	    mask = smartputComputeResize (window, &xwc);
	    if (mask)
	    {
		if (constrainNewWindowSize (window, xwc.width, xwc.height,
					    &width, &height))
		{
		    mask |= CWWidth | CWHeight;
		    xwc.width  = width;
		    xwc.height = height;
		}

		if (window->mapNum && (mask & (CWWidth | CWHeight)))
		    sendSyncRequest (window);

		configureXWindow (window, mask, &xwc);
	    }
	}
    }
    if(grabIndex)
	removeScreenGrab (s,grabIndex, NULL);
    return TRUE;
}
Exemple #24
0
static void
moveHandleEvent(CompDisplay *d,
                XEvent      *event)
{
   CompScreen *s;

   MOVE_DISPLAY (d);

   switch (event->type)
     {
      case ClientMessage:
        if (event->xclient.message_type == d->eManagedAtom)
          {
             CompWindow *w;

             Window win = event->xclient.window;
             unsigned int type = event->xclient.data.l[0];
             if (type != 4) break;

             w = findWindowAtDisplay (d, win);
             if (w)
               {
                  unsigned int state = event->xclient.data.l[2];
                  s = w->screen;

                  if(state)
                    {
                       CompOption o[1];
                       CompAction *action = NULL;

                       o[0].type = CompOptionTypeInt;
                       o[0].name = "window";
                       o[0].value.i = w->id;

                       moveInitiate (d, action, CompActionStateInitButton, o, 1);
                       MOVE_SCREEN(s);

                       ms->active = 1;
                    }
                  else
                    {
                       moveTerminate (d, NULL, 0, NULL, 0);
                    }
               }
          }

        break;

      case DestroyNotify:
        if (md->w && md->w->id == event->xdestroywindow.window)
          moveTerminate (d, NULL, 0, NULL, 0);
        break;

      case UnmapNotify:
        if (md->w && md->w->id == event->xunmap.window)
          moveTerminate (d, NULL, 0, NULL, 0);

      default:
        break;
     }

   UNWRAP (md, d, handleEvent);
   (*d->handleEvent)(d, event);
   WRAP (md, d, handleEvent, moveHandleEvent);
}
static void
smartputHandleEvent (CompDisplay *d,
		    XEvent      *event)
{
    SMARTPUT_DISPLAY (d);

    switch (event->type)
    {
	/* handle client events */
    case ClientMessage:
	/* accept the custom atom for putting windows */
	if (event->xclient.message_type == spd->compizSmartputWindowAtom)
	{
	    CompWindow *w;

	    w = findWindowAtDisplay (d, event->xclient.window);
	    if (w)
	    {
		/*
		 * get the values from the xclientmessage event and populate
		 * the options for put initiate
		 *
		 * the format is 32
		 * and the data is
		 * l[0] = x position - unused (for future PutExact)
		 * l[1] = y position - unused (for future PutExact)
		 * l[2] = face number
		 * l[3] = put type, int value from enum
		 * l[4] = Xinerama head number
		 */
		CompOption opt[5];

		opt[0].type    = CompOptionTypeInt;
		opt[0].name    = "window";
		opt[0].value.i = event->xclient.window;

		opt[1].type    = CompOptionTypeInt;
		opt[1].name    = "x";
		opt[1].value.i = event->xclient.data.l[0];

		opt[2].type    = CompOptionTypeInt;
		opt[2].name    = "y";
		opt[2].value.i = event->xclient.data.l[1];

		opt[3].type    = CompOptionTypeInt;
		opt[3].name    = "face";
		opt[3].value.i = event->xclient.data.l[2];

		opt[4].type    = CompOptionTypeInt;
		opt[4].name    = "head";
		opt[4].value.i = event->xclient.data.l[4];

		smartputTrigger (w->screen->display, NULL, 0, opt, 5);
	    }
	}
	break;
    default:
	break;
    }

    UNWRAP (spd, d, handleEvent);
    (*d->handleEvent) (d, event);
    WRAP (spd, d, handleEvent, smartputHandleEvent);
}
Exemple #26
0
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;
                    }
               }
          }
     }
}
static Bool
scaleaddonZoomWindow(CompDisplay * d,
		     CompAction * action,
		     CompActionState state, CompOption * option, int nOption)
{
	CompScreen *s;
	Window xid;

	xid = getIntOptionNamed(option, nOption, "root", 0);

	s = findScreenAtDisplay(d, xid);
	if (s) {
		CompWindow *w;

		SCALE_SCREEN(s);
		ADDON_DISPLAY(d);

		if (!ss->grabIndex)
			return FALSE;

		w = findWindowAtDisplay(d, ad->highlightedWindow);
		if (w) {
			SCALE_WINDOW(w);
			ADDON_WINDOW(w);

			XRectangle outputRect;
			BOX outputBox;
			int head;

			if (!sw->slot)
				return FALSE;

			head =
			    outputDeviceForPoint(s, sw->slot->x1, sw->slot->y1);
			outputBox = w->screen->outputDev[head].region.extents;

			outputRect.x = outputBox.x1;
			outputRect.y = outputBox.y1;
			outputRect.width = outputBox.x2 - outputBox.x1;
			outputRect.height = outputBox.y2 - outputBox.y1;

			/* damage old rect */
			addWindowDamage(w);

			if (!aw->rescaled) {
				aw->oldAbove = w->next;
				raiseWindow(w);

				/* backup old values */
				aw->origSlot = *sw->slot;

				aw->rescaled = TRUE;

				sw->slot->x1 =
				    (outputRect.width / 2) - (WIN_W(w) / 2) +
				    w->input.left + outputRect.x;
				sw->slot->y1 =
				    (outputRect.height / 2) - (WIN_H(w) / 2) +
				    w->input.top + outputRect.y;
				sw->slot->x2 = sw->slot->x1 + WIN_W(w);
				sw->slot->y2 = sw->slot->y1 + WIN_H(w);
				sw->slot->scale = 1.0f;
			} else {
				if (aw->oldAbove)
					restackWindowBelow(w, aw->oldAbove);

				aw->rescaled = FALSE;
				*(sw->slot) = aw->origSlot;
			}

			sw->adjust = TRUE;
			ss->state = SCALE_STATE_OUT;

			/* slot size may have changed, so
			 * update window title */
			scaleaddonRenderWindowTitle(w);

			addWindowDamage(w);

			return TRUE;
		}
	}

	return FALSE;
}
static Bool
scaleaddonPullWindow(CompDisplay * d,
		     CompAction * action,
		     CompActionState state, CompOption * option, int nOption)
{
	CompScreen *s;
	Window xid;

	xid = getIntOptionNamed(option, nOption, "root", 0);

	s = findScreenAtDisplay(d, xid);
	if (s) {
		CompWindow *w;

		SCALE_SCREEN(s);
		ADDON_DISPLAY(d);

		if (!ss->grabIndex)
			return FALSE;

		w = findWindowAtDisplay(d, ad->highlightedWindow);
		if (w) {
			int x, y, vx, vy;

			defaultViewportForWindow(w, &vx, &vy);

			x = w->attrib.x + (s->x - vx) * s->width;
			y = w->attrib.y + (s->y - vy) * s->height;

			if (scaleaddonGetConstrainPullToScreen(s)) {
				XRectangle workArea;
				CompWindowExtents extents;

				getWorkareaForOutput(s,
						     outputDeviceForWindow(w),
						     &workArea);

				extents.left = x - w->input.left;
				extents.right = x + w->width + w->input.right;
				extents.top = y - w->input.top;
				extents.bottom =
				    y + w->height + w->input.bottom;

				if (extents.left < workArea.x)
					x += workArea.x - extents.left;
				else if (extents.right >
					 workArea.x + workArea.width)
					x += workArea.x + workArea.width -
					    extents.right;

				if (extents.top < workArea.y)
					y += workArea.y - extents.top;
				else if (extents.bottom >
					 workArea.y + workArea.height)
					y += workArea.y + workArea.height -
					    extents.bottom;
			}

			if (x != w->attrib.x || y != w->attrib.y) {
				SCALE_WINDOW(w);

				moveWindowToViewportPosition(w, x, y, TRUE);

				/* Select this window when ending scale */
				(*ss->selectWindow) (w);

				/* stop scaled window dissapearing */
				sw->tx -= (s->x - vx) * s->width;
				sw->ty -= (s->y - vy) * s->height;

				if (scaleaddonGetExitAfterPull(s)) {
					int opt;
					CompAction *action2;
					CompOption o[1];

					SCALE_DISPLAY(d);

					opt = SCALE_DISPLAY_OPTION_INITIATE_KEY;
					action2 = &sd->opt[opt].value.action;

					o[0].type = CompOptionTypeInt;
					o[0].name = "root";
					o[0].value.i = s->root;

					if (action2->terminate)
						(*action2->terminate) (d,
								       action,
								       0, o, 1);
				} else {
					/* provide a simple animation */
					addWindowDamage(w);

					sw->tx -=
					    (sw->slot->x2 - sw->slot->x1) / 20;
					sw->ty -=
					    (sw->slot->y2 - sw->slot->y1) / 20;
					sw->scale *= 1.1f;
					sw->adjust = TRUE;

					ss->state = SCALE_STATE_OUT;
					addWindowDamage(w);
				}

				return TRUE;
			}
		}
	}

	return FALSE;
}
Exemple #29
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;
	}
}
Exemple #30
0
static void
videoHandleEvent(CompDisplay *d,
                 XEvent *event)
{
   CompWindow *w;

   VIDEO_DISPLAY(d);

   switch (event->type)
     {
      case PropertyNotify:
        if (event->xproperty.atom == vd->videoAtom)
          {
             w = findWindowAtDisplay(d, event->xproperty.window);
             if (w)
               videoWindowUpdate(w);
          }
        break;

      default:
        if (event->type == d->damageEvent + XDamageNotify)
          {
             XDamageNotifyEvent *de = (XDamageNotifyEvent *)event;
             VideoTexture *t;

             for (t = vd->textures; t; t = t->next)
               {
                  if (t->pixmap == de->drawable)
                    {
                       VideoWindow *vw;
                       VideoScreen *vs;
                       CompScreen *s;
                       BoxRec box;
                       int bw;

                       t->texture.oldMipmaps = TRUE;

                       for (s = d->screens; s; s = s->next)
                         {
                            vs = GET_VIDEO_SCREEN(s, vd);

                            for (w = s->windows; w; w = w->next)
                              {
                                 if (w->shaded || w->mapNum)
                                   {
                                      vw = GET_VIDEO_WINDOW(w, vs);

                                      if (vw->context &&
                                          vw->context->source->texture == t)
                                        {
                                           box = vw->context->box.extents;

                                           bw = w->attrib.border_width;

                                           box.x1 -= w->attrib.x + bw;
                                           box.y1 -= w->attrib.y + bw;
                                           box.x2 -= w->attrib.x + bw;
                                           box.y2 -= w->attrib.y + bw;

                                           addWindowDamageRect(w, &box);
                                        }
                                   }
                              }
                         }
                       return;
                    }
               }
          }
        break;
     }

   UNWRAP(vd, d, handleEvent);
   (*d->handleEvent)(d, event);
   WRAP(vd, d, handleEvent, videoHandleEvent);
}