2
* Compiz Fusion Freewins plugin
6
* Copyright (C) 2007 Rodolfo Granata <warlock.cc@gmail.com>
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* as published by the Free Software Foundation; either version 2
11
* of the License, or (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
19
* Rodolfo Granata <warlock.cc@gmail.com>
20
* Sam Spilsbury <smspillaz@gmail.com>
22
* Button binding support and Reset added by:
23
* enigma_0Z <enigma.0ZA@gmail.com>
25
* Most of the input handling here is based on
27
* : Kristian Lyngstøl <kristian@bohemians.org>
28
* : Danny Baumann <maniac@opencompositing.org>
32
* This plugin allows you to freely transform the texture of a window,
33
* whether that be rotation or scaling to make better use of screen space
37
* - Modifier key to rotate on the Z Axis
38
* - Fully implement an input redirection system by
39
* finding an inverse matrix, multiplying by it,
40
* translating to the actual window co-ords and
41
* XSendEvent() the co-ords to the actual window.
42
* - Code could be cleaner
43
* - Add timestep and speed options to animation
44
* - Add window hover-over info via paintOutput : i.e
53
COMPIZ_PLUGIN_20090315 (freewins, FWPluginVTable);
55
/* Information on window resize */
57
FWWindow::resizeNotify (int dx,
62
calculateInputRect ();
64
int x = WIN_REAL_X(window) + WIN_REAL_W(window)/2.0;
65
int y = WIN_REAL_Y(window) + WIN_REAL_H(window)/2.0;
67
mRadius = sqrt(pow((x - WIN_REAL_X (window)), 2) + pow((y - WIN_REAL_Y (window)), 2));
69
window->resizeNotify (dx, dy, dw, dh);
73
FWWindow::moveNotify (int dx,
77
FREEWINS_SCREEN (screen);
79
/* Did we move and IPW and not the actual window? */
80
CompWindow *useWindow = fws->getRealWindow (window);
83
useWindow->move (dx, dy, fws->optionGetImmediateMoves ());
84
else if (window != fws->mGrabWindow)
90
int x = WIN_REAL_X (useWindow) + WIN_REAL_W (useWindow) /2.0;
91
int y = WIN_REAL_Y (useWindow) + WIN_REAL_H (useWindow) /2.0;
94
mRadius = sqrt (pow((x - WIN_REAL_X (useWindow)), 2) + pow ((y - WIN_REAL_Y (useWindow)), 2));
96
useWindow->moveNotify (dx, dy, immediate);
100
FWScreen::reloadSnapKeys ()
102
unsigned int imask = optionGetInvertModsMask ();
105
if (imask & InvertModsShiftMask)
106
mInvertMask |= ShiftMask;
107
if (imask & InvertModsAltMask)
108
mInvertMask |= CompAltMask;
109
if (imask & InvertModsControlMask)
110
mInvertMask |= ControlMask;
111
if (imask & InvertModsMetaMask)
112
mInvertMask |= CompMetaMask;
114
unsigned int smask = optionGetSnapModsMask ();
116
if (smask & SnapModsShiftMask)
117
mSnapMask |= ShiftMask;
118
if (smask & SnapModsAltMask)
119
mSnapMask |= CompAltMask;
120
if (smask & SnapModsControlMask)
121
mSnapMask |= ControlMask;
122
if (smask & SnapModsMetaMask)
123
mSnapMask |= CompMetaMask;
127
FWScreen::optionChanged (CompOption *option,
128
FreewinsOptions::Options num)
132
case FreewinsOptions::SnapMods:
133
case FreewinsOptions::InvertMods:
141
/* ------ Plugin Initialisation ---------------------------------------*/
143
/* Window initialisation / cleaning */
145
FWWindow::FWWindow (CompWindow *w) :
146
PluginClassHandler <FWWindow, CompWindow> (w),
148
cWindow (CompositeWindow::get (w)),
149
gWindow (GLWindow::get (w)),
150
mIMidX (WIN_REAL_W (w) / 2.0),
151
mIMidY (WIN_REAL_H (w) / 2.0),
161
mCorner (CornerTopLeft),
163
mOutputRect (w->outputRect ()),
164
mInputRect (w->borderRect ()),
166
mIsAnimating (false),
169
mTransformed (false),
172
WindowInterface::setHandler (window);
173
CompositeWindowInterface::setHandler (cWindow);
174
GLWindowInterface::setHandler (gWindow);
176
int x = WIN_REAL_X (w) + WIN_REAL_W (w) /2.0;
177
int y = WIN_REAL_Y (w) + WIN_REAL_H (w) /2.0;
179
mRadius = sqrt (pow ((x - WIN_REAL_X (w)), 2) + pow ((y - WIN_REAL_Y (w)), 2));
182
FWWindow::~FWWindow ()
185
handleWindowInputInfo ();
187
FREEWINS_SCREEN (screen);
189
if (fws->mGrabWindow == window)
190
fws->mGrabWindow = NULL;
193
#define ROTATE_INC optionGetRotateIncrementAmount ()
194
#define NEG_ROTATE_INC optionGetRotateIncrementAmount () *-1
196
#define SCALE_INC optionGetScaleIncrementAmount ()
197
#define NEG_SCALE_INC optionGetScaleIncrementAmount () *-1
199
FWScreen::FWScreen (CompScreen *screen) :
200
PluginClassHandler <FWScreen, CompScreen> (screen),
201
cScreen (CompositeScreen::get (screen)),
202
gScreen (GLScreen::get (screen)),
207
mLastGrabWindow (NULL),
215
ScreenInterface::setHandler (screen);
216
CompositeScreenInterface::setHandler (cScreen);
217
GLScreenInterface::setHandler (gScreen);
219
/* TODO: warning about shape! */
221
/* BCOP Action initiation */
222
optionSetInitiateRotationButtonInitiate (boost::bind (&FWScreen::initiateFWRotate, this, _1, _2, _3));
223
optionSetInitiateRotationButtonTerminate (boost::bind (&FWScreen::terminateFWRotate, this, _1, _2, _3));
224
optionSetInitiateScaleButtonInitiate (boost::bind (&FWScreen::initiateFWScale, this, _1, _2, _3));
225
optionSetInitiateScaleButtonTerminate (boost::bind (&FWScreen::terminateFWScale, this, _1, _2, _3));
226
optionSetResetButtonInitiate (boost::bind (&FWScreen::resetFWTransform, this, _1, _2, _3));
227
optionSetResetKeyInitiate (boost::bind (&FWScreen::resetFWTransform, this, _1, _2, _3));
228
optionSetToggleAxisKeyInitiate (boost::bind (&FWScreen::toggleFWAxis, this, _1, _2, _3));
230
// Rotate / Scale Up Down Left Right TODO: rebind these actions on option change
232
optionSetScaleUpButtonInitiate (boost::bind (&FWScreen::scale, this, _1, _2, _3, SCALE_INC));
233
optionSetScaleDownButtonInitiate (boost::bind (&FWScreen::scale, this, _1, _2, _3, NEG_SCALE_INC));
234
optionSetScaleUpKeyInitiate (boost::bind (&FWScreen::scale, this, _1, _2, _3, SCALE_INC));
235
optionSetScaleDownKeyInitiate (boost::bind (&FWScreen::scale, this, _1, _2, _3, NEG_SCALE_INC));
237
optionSetRotateUpKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, 0, ROTATE_INC, 0));
238
optionSetRotateDownKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, 0, NEG_ROTATE_INC, 0));
239
optionSetRotateLeftKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, ROTATE_INC, 0, 0));
240
optionSetRotateRightKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, NEG_ROTATE_INC, 0, 0));
241
optionSetRotateCKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, 0, 0, ROTATE_INC));
242
optionSetRotateCcKeyInitiate (boost::bind (&FWScreen::rotate, this, _1, _2, _3, 0, 0, NEG_ROTATE_INC));
244
optionSetRotateInitiate (boost::bind (&FWScreen::rotateAction, this, _1, _2, _3));
245
optionSetIncrementRotateInitiate (boost::bind (&FWScreen::incrementRotateAction, this, _1, _2, _3));
246
optionSetScaleInitiate (boost::bind (&FWScreen::scaleAction, this, _1, _2, _3));
248
optionSetSnapModsNotify (boost::bind (&FWScreen::optionChanged, this, _1, _2));
249
optionSetInvertModsNotify (boost::bind (&FWScreen::optionChanged, this, _1, _2));
255
FWPluginVTable::init ()
257
if (!screen->XShape ())
259
compLogMessage ("shelf", CompLogLevelError,
260
"No Shape extension found. IPW Usage not enabled \n");
263
if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) &&
264
CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) &&
265
CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))