/** * * Compiz tile plugin * * tile.c * * Copyright (c) 2006 Atie H. * Copyright (c) 2006 Michal Fojtik * Copyright (c) 2007 Danny Baumann * * Rewritten by: * Copyright (c) 2008 Sam Spilsbury * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * TODO * - change vertical and horizontal tiling to similar behavior as Left * - fix bugs * - make vertical and horizontal maximization be saved when tiling * **/ #include #include #include #include #include "tile_options.h" #include class Tiler; class TileScreen : public PrivateHandler , public TileOptions, public ScreenInterface, public CompositeScreenInterface, public GLScreenInterface { public: typedef enum { Normal = 0, In, Tiled, Out } State; typedef enum { Restore = 0, Square, Even, Horizontal, Vertical, Expand, Organic, Cascade } TileType; public: TileScreen (CompScreen *screen); CompositeScreen *cScreen; GLScreen *gScreen; State state; int time; /* Tiling queue */ std::list tilers; CompRect nextPosition; TileType type; void preparePaint (int); /* finsih */ bool glPaintOutput (const GLScreenPaintAttrib &attrib, const GLMatrix &transform, CompRegion ®ion, CompOutput *output, unsigned int mask); #if 0 bool glPaintScreen (CompOutput *outputs, int numOutputs, unsigned int mask); //for ensuring fullscreen output; #endif void donePaint (); /* Tiling modes */ void restoreTile (CompWindowExtents &border, XRectangle &workArea, int count); void squareTile (CompWindowExtents &border, XRectangle &workArea, int count); void horizontalTile (CompWindowExtents &border, XRectangle &workArea, int count); void verticalTile (CompWindowExtents &border, XRectangle &workArea, int count); void evenTile (CompWindowExtents &border, XRectangle &workArea, int count); void expandTile (CompWindowExtents &border, XRectangle &workArea, int count); void organicTile (CompWindowExtents &border, XRectangle &workArea, int count); void cascadeTile (CompWindowExtents &border, XRectangle &workArea, int count); /* Actions */ bool applyTiling (CompAction *action, CompAction::State state, CompOption::Vector options, TileType type); }; #define TILE_SCREEN(s) \ TileScreen *ts = TileScreen::get (s); class Tiler { public: Tiler (); public: typedef enum { NotTiled = 0, WaitingForTile, WaitingForRestore, Tiled } State; public: State state; bool maximized; int savedMaxState; CompRect saved; CompRect previous; CompRect current; bool configure (CompWindow *, TileScreen::TileType); void save (CompWindow *); }; class TileWindow : public PrivateHandler , public WindowInterface, public GLWindowInterface { public: TileWindow (CompWindow *window); ~TileWindow (); CompWindow *window; GLWindow *gWindow; bool animate; int outlineColor[3]; int time; bool alreadyResized; bool needConfigure; Tiler *tiler; void resizeNotify (int, int, int, int); bool glPaint (const GLWindowPaintAttrib &attrib, const GLMatrix &transform, CompRegion ®ion, unsigned int mask); void constrainMinMax (int width, int height, int &newWidth, int &newHeight); bool placeWin (int x, int y, unsigned int width, unsigned int height); bool is (); }; #define TILE_WINDOW(w) \ TileWindow *tw = TileWindow::get (w); class TilePluginVTable : public CompPlugin::VTableForScreenAndWindow { public: bool init (); PLUGIN_OPTION_HELPER (TileScreen); };