summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-08-20 01:27:15 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-08-20 01:27:15 +0800
commit16f774f18ecfbd2fd38f1d8765f43ab7a74b249d (patch)
tree5e961f143857d3c1db5cdafa49620b739e4231fd
parent535e9bdfb755a07bde2b7567314aa5e3de30a361 (diff)
downloadwinreflect-16f774f18ecfbd2fd38f1d8765f43ab7a74b249d.tar.gz
winreflect-16f774f18ecfbd2fd38f1d8765f43ab7a74b249d.tar.bz2
Remove "reflect docks" and instead add window matches list
-rw-r--r--src/winreflect.cpp134
-rw-r--r--src/winreflect.h5
-rw-r--r--winreflect.xml.in48
3 files changed, 124 insertions, 63 deletions
diff --git a/src/winreflect.cpp b/src/winreflect.cpp
index 2c7a7e2..9d9e52f 100644
--- a/src/winreflect.cpp
+++ b/src/winreflect.cpp
@@ -96,46 +96,83 @@ WinreflectScreen::updateReflectionProperty (Window id)
}
void
-WinreflectScreen::optionChange (CompOption *opt,
- Options num)
-{
- switch (num)
+WinreflectScreen::updateReflections ()
+{
+ CompOption::Value::Vector wins = optionGetReflectiveWindows ();
+ CompOption::Value::Vector xs = optionGetReflectiveAreaX ();
+ CompOption::Value::Vector ys = optionGetReflectiveAreaY ();
+ CompOption::Value::Vector widths = optionGetReflectiveAreaWidth ();
+ CompOption::Value::Vector heights = optionGetReflectiveAreaHeight ();
+ std::list <ReflectionRegion>::iterator it = mReflectedRegions.begin ();
+
+ /* Remove reflections with "None" window id */
+
+ while (it != mReflectedRegions.end ())
{
- case WinreflectOptions::ReflectDocks:
+ ReflectionRegion &r = *it;
+
+ it++;
+
+ if (r.id == None)
{
- if (opt->value ().b ())
- {
- foreach (CompWindow *w, screen->windows ())
- {
- if (w->type () == CompWindowTypeDockMask)
- {
- CompRect in (w->inputRect ());
- ReflectionRegion r (in);
-
- r.id = w->id ();
-
- mReflectedRegions.push_back (r);
- }
- }
- }
- else
+ mReflectedRegions.remove (r);
+ it = mReflectedRegions.begin ();
+ }
+ }
+
+ foreach (CompOption::Value &v, wins)
+ {
+ foreach (CompWindow *w, screen->windows ())
+ {
+ if (v.match ().evaluate (w))
{
- std::list <ReflectionRegion>::iterator it = mReflectedRegions.begin ();
+ CompRect in (w->inputRect ());
+ ReflectionRegion r (in);
- while (it != mReflectedRegions.end ())
- {
- ReflectionRegion r = *it;
- CompWindow *w = screen->findWindow (r.id);
-
- if (w && w->type () == CompWindowTypeDockMask)
- {
- mReflectedRegions.remove (r);
- it = mReflectedRegions.begin ();
- }
- it++;
- }
+ r.id = None;
+
+ mReflectedRegions.push_back (r);
}
}
+ }
+
+ if (xs.size () != ys.size () ||
+ ys.size () != widths.size () ||
+ widths.size () != heights.size () ||
+ heights.size () != xs.size ())
+ {
+ compLogMessage ("winreflect", CompLogLevelWarn, "Values items do not match\n");
+ return;
+ }
+
+ for (unsigned int i = 0; i < xs.size (); i++)
+ {
+ int x = xs.at (i).i ();
+ int y = ys.at (i).i ();
+ int width = widths.at (i).i ();
+ int height = heights.at (i).i ();
+
+ CompRect size (x, y, width, height);
+ ReflectionRegion r (size);
+
+ r.id = None;
+
+ mReflectedRegions.push_back (r);
+ }
+}
+
+void
+WinreflectScreen::optionChange (CompOption *opt,
+ Options num)
+{
+ switch (num)
+ {
+ case WinreflectOptions::ReflectiveWindows:
+ case WinreflectOptions::ReflectiveAreaX:
+ case WinreflectOptions::ReflectiveAreaY:
+ case WinreflectOptions::ReflectiveAreaWidth:
+ case WinreflectOptions::ReflectiveAreaHeight:
+ updateReflections ();
default:
break;
}
@@ -161,28 +198,7 @@ WinreflectScreen::handleEvent (XEvent *event)
}
break;
case ConfigureNotify:
- foreach (ReflectionRegion &r, mReflectedRegions)
- {
- if (event->xconfigure.window = r.id)
- {
- CompWindow *w = screen->findWindow (r.id);
-
- if (w->type () == CompWindowTypeDockMask &&
- optionGetReflectDocks ())
- {
- CompRect in (w->inputRect ());
- ReflectionRegion nR (in);
-
- mReflectedRegions.remove (r);
-
- nR.id = w->id ();
-
- mReflectedRegions.push_back (nR);
-
- break;
- }
- }
- }
+ updateReflections ();
break;
default:
break;
@@ -326,7 +342,11 @@ WinreflectScreen::WinreflectScreen (CompScreen *s) :
ScreenInterface::setHandler (screen);
GLScreenInterface::setHandler (gScreen);
- optionSetReflectDocksNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
+ optionSetReflectiveWindowsNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
+ optionSetReflectiveAreaXNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
+ optionSetReflectiveAreaYNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
+ optionSetReflectiveAreaWidthNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
+ optionSetReflectiveAreaHeightNotify (boost::bind (&WinreflectScreen::optionChange, this, _1, _2));
}
bool
diff --git a/src/winreflect.h b/src/winreflect.h
index 30c0483..943fb85 100644
--- a/src/winreflect.h
+++ b/src/winreflect.h
@@ -38,7 +38,7 @@ class ReflectionRegion :
ReflectionRegion (CompRegion &r) :
CompRegion::CompRegion (r) {};
- unsigned int id;
+ Window id;
};
@@ -64,6 +64,9 @@ class WinreflectScreen :
handleEvent (XEvent *);
void
+ updateReflections ();
+
+ void
optionChange (CompOption *, Options);
bool
diff --git a/winreflect.xml.in b/winreflect.xml.in
index c66cb15..9762652 100644
--- a/winreflect.xml.in
+++ b/winreflect.xml.in
@@ -16,11 +16,49 @@
<min>0</min>
<max>100</max>
</option>
- <option name="reflect_docks" type="bool">
- <_short>Reflect Docks</_short>
- <_long>Add reflection area to docks by default. Note that this will not look correct on nonrectangular docks, they should set a hint instead</_long>
- <default>false</default>
- </option>
+ <subgroup>
+ <_short>Reflective Windows</_short>
+ <option name="reflective_windows" type="list">
+ <_short>Reflective Windows</_short>
+ <_long>Windows which have a reflective surface by default</_long>
+ <type>match</type>
+ </option>
+ </subgroup>
+ <subgroup>
+ <_short>Reflective Areas</_short>
+ <option name="reflective_area_x" type="list">
+ <_short>X Position</_short>
+ <_long>X Position of reflective area</_long>
+ <default>0</default>
+ <min>0</min>
+ <max>5000</max>
+ <type>int</type>
+ </option>
+ <option name="reflective_area_y" type="list">
+ <_short>Y Position</_short>
+ <_long>Y Position of reflective area</_long>
+ <default>0</default>
+ <min>0</min>
+ <max>5000</max>
+ <type>int</type>
+ </option>
+ <option name="reflective_area_width" type="list">
+ <_short>Width</_short>
+ <_long>Width of reflective area</_long>
+ <default>0</default>
+ <min>0</min>
+ <max>5000</max>
+ <type>int</type>
+ </option>
+ <option name="reflective_area_height" type="list">
+ <_short>Height</_short>
+ <_long>Height of reflective area</_long>
+ <default>0</default>
+ <min>0</min>
+ <max>5000</max>
+ <type>int</type>
+ </option>
+ </subgroup>
</options>
</plugin>
</compiz>