static void gridChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { GRID_DISPLAY (&display); if (strcasecmp (optionName, "put_center_key") == 0) updateKey (optionValue->s, &gd->put_center_key); else if (strcasecmp (optionName, "put_left_key") == 0) updateKey (optionValue->s, &gd->put_left_key); else if (strcasecmp (optionName, "put_right_key") == 0) updateKey (optionValue->s, &gd->put_right_key); else if (strcasecmp (optionName, "put_top_key") == 0) updateKey (optionValue->s, &gd->put_top_key); else if (strcasecmp (optionName, "put_bottom_key") == 0) updateKey (optionValue->s, &gd->put_bottom_key); else if (strcasecmp (optionName, "put_topleft_key") == 0) updateKey (optionValue->s, &gd->put_topleft_key); else if (strcasecmp (optionName, "put_topright_key") == 0) updateKey (optionValue->s, &gd->put_topright_key); else if (strcasecmp (optionName, "put_bottomleft_key") == 0) updateKey (optionValue->s, &gd->put_bottomleft_key); else if (strcasecmp (optionName, "put_bottomright_key") == 0) updateKey (optionValue->s, &gd->put_bottomright_key); }
static void gridFiniDisplay (CompPlugin *p, CompDisplay *d) { GRID_DISPLAY (d); UNWRAP (gd, d, handleEvent); free (gd); }
static void gridFiniDisplay (CompPlugin *p, CompDisplay *d) { GRID_DISPLAY (d); freeScreenPrivateIndex (d, gd->screenPrivateIndex); UNWRAP (gd, d, handleEvent); free (gd); }
static Bool gridInitScreen (CompPlugin *p, CompScreen *s) { GridScreen * gs; GRID_DISPLAY (s->display); gs = malloc (sizeof (GridScreen)); if (!gs) return FALSE; gs->grabIsMove = FALSE; gs->edge = NoEdge; gs->lastEdge = NoEdge; gs->drawing = FALSE; gs->w = 0; gs->anim.progress = 0.0f; gs->anim.fromRect.x = 0; gs->anim.fromRect.y = 0; gs->anim.fromRect.width = 0; gs->anim.fromRect.height =0; gs->anim.targetRect.x = 0; gs->anim.targetRect.y = 0; gs->anim.targetRect.width = 0; gs->anim.targetRect.height = 0; gs->anim.currentRect.x = 0; gs->anim.currentRect.y = 0; gs->anim.currentRect.width = 0; gs->anim.currentRect.height = 0; gs->anim.opacity = 0.5f; gs->anim.timer = 0.0f; gs->anim.duration = 0; gs->anim.complete = FALSE; gs->anim.fadingOut = FALSE; gs->animating=FALSE; WRAP (gs, s, windowGrabNotify, gridWindowGrabNotify); WRAP (gs, s, windowUngrabNotify, gridWindowUngrabNotify); WRAP (gs, s, paintOutput, gridPaintOutput); WRAP (gs, s, preparePaintScreen, gridPreparePaintScreen); s->base.privates[gd->screenPrivateIndex].ptr = gs; return TRUE; }
static void gridHandleEvent (XEvent *event) { GRID_DISPLAY (&display); switch (event->type) { case KeyPress: if (isKeyPressEvent (event, &gd->put_center_key)) gridPlaceWindow (display.activeWindow, GridCenter); else if (isKeyPressEvent (event, &gd->put_left_key)) gridPlaceWindow (display.activeWindow, GridLeft); else if (isKeyPressEvent (event, &gd->put_right_key)) gridPlaceWindow (display.activeWindow, GridRight); else if (isKeyPressEvent (event, &gd->put_top_key)) gridPlaceWindow (display.activeWindow, GridTop); else if (isKeyPressEvent (event, &gd->put_bottom_key)) gridPlaceWindow (display.activeWindow, GridBottom); else if (isKeyPressEvent (event, &gd->put_topleft_key)) gridPlaceWindow (display.activeWindow, GridTopLeft); else if (isKeyPressEvent (event, &gd->put_topright_key)) gridPlaceWindow (display.activeWindow, GridTopRight); else if (isKeyPressEvent (event, &gd->put_bottomleft_key)) gridPlaceWindow (display.activeWindow, GridBottomLeft); else if (isKeyPressEvent (event, &gd->put_bottomright_key)) gridPlaceWindow (display.activeWindow, GridBottomRight); break; default: break; } UNWRAP (gd, &display, handleEvent); (*display.handleEvent) (event); WRAP (gd, &display, handleEvent, gridHandleEvent); }
static void gridHandleEvent (CompDisplay *d, XEvent *event) { GridType where; GRID_DISPLAY (d); if (event->type == MotionNotify) { CompScreen *s; s = findScreenAtDisplay (d, event->xmotion.root); if (s) { GRID_SCREEN (s); if (gs->grabIsMove) { /* detect corners first */ /* Bottom Left */ if (pointerY > (s->height - gridGetBottomEdgeThreshold(d)) && pointerX < gridGetLeftEdgeThreshold(d)) gs->edge = BottomLeft; /* Bottom Right */ else if (pointerY > (s->height - gridGetBottomEdgeThreshold(d)) && pointerX > (s->width - gridGetRightEdgeThreshold(d))) gs->edge = BottomRight; /* Top Left */ else if (pointerY < gridGetTopEdgeThreshold(d) && pointerX < gridGetLeftEdgeThreshold(d)) gs->edge = TopLeft; /* Top Right */ else if (pointerY < gridGetTopEdgeThreshold(d) && pointerX > (s->width - gridGetRightEdgeThreshold(d))) gs->edge = TopRight; /* Left */ else if (pointerX < gridGetLeftEdgeThreshold(d)) gs->edge = Left; /* Right */ else if (pointerX > (s->width - gridGetRightEdgeThreshold(d))) gs->edge = Right; /* Top */ else if (pointerY < gridGetTopEdgeThreshold(d)) gs->edge = Top; /* Bottom */ else if (pointerY > (s->height - gridGetBottomEdgeThreshold(d))) gs->edge = Bottom; /* No Edge */ else gs->edge = NoEdge; /* detect edge region change */ if (gs->lastEdge != gs->edge) { if (gs->edge != NoEdge) { where = edgeToGridType(d, gs->edge); /* treat Maximize visual indicator same as GridCenter */ if (where == GridMaximize) where=GridCenter; getTargetRect (gs->w, where); gs->anim.duration = gridGetAnimationDuration (d); gs->anim.timer = gs->anim.duration; gs->anim.opacity = 0.0f; gs->anim.progress = 0.0f; gs->anim.currentRect.x = gs->w->serverX; gs->anim.currentRect.y = gs->w->serverY; gs->anim.currentRect.width = gs->w->serverWidth; gs->anim.currentRect.height = gs->w->serverHeight; gs->anim.targetRect = gs->desiredSlot; gs->anim.fromRect.x = gs->w->serverX - gs->w->input.left; gs->anim.fromRect.y = gs->w->serverY - gs->w->input.top; gs->anim.fromRect.width = gs->w->serverWidth + gs->w->input.left + gs->w->input.right + gs->w->serverBorderWidth * 2; gs->anim.fromRect.height = gs->w->serverHeight + gs->w->input.top + gs->w->input.bottom + gs->w->serverBorderWidth * 2; gs->animating = TRUE; gs->anim.fadingOut = FALSE; } else gs->anim.fadingOut = TRUE; gs->lastEdge = gs->edge; } } } } UNWRAP (gd, d, handleEvent); (*d->handleEvent) (d, event); WRAP (gd, d, handleEvent, gridHandleEvent); }