Merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-dialog into lp:compiz/0.9.9

Proposed by MC Return on 2013-01-09
Status: Superseded
Proposed branch: lp:~mc-return/compiz/compiz0.9.9.merge-plugin-dialog
Merge into: lp:compiz/0.9.9
Diff against target: 353 lines (+332/-0)
4 files modified
plugins/dialog/CMakeLists.txt (+5/-0)
plugins/dialog/dialog.xml.in (+68/-0)
plugins/dialog/src/dialog.cpp (+158/-0)
plugins/dialog/src/dialog.h (+101/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-dialog
Reviewer Review Type Date Requested Status
Compiz Maintainers 2013-01-09 Pending
Review via email: mp+142611@code.launchpad.net

Commit message

Adds the plug-in "Dialog Dim" converted from git to bzr (including full history) to lp:compiz.

Description of the change

This plugin currently has quite a few problems and is not ready for merge yet:

* Although saturation seems to be correctly implemented, saturation always seems to be 1.0

* The speed setting has no effect whatsoever

* Parent windows sometimes get stuck in their faded state, which ofc is inacceptable

* Default settings could be better

To post a comment you must log in.

Unmerged revisions

3293. By MC Return on 2013-01-09

Merged latest lp:compiz

3292. By MC Return on 2012-08-18

Reverted last commit and fixed the right typo this time

3291. By MC Return on 2012-08-18

Fixed typo

3290. By MC Return on 2012-08-18

Fixed a few of the tooltips

3289. By MC Return on 2012-08-18

Hopefully fixed indentation

3288. By MC Return on 2012-08-18

Removed plugins/dialog/VERSION

3287. By MC Return on 2012-07-22

Added the plug-in "Dialog Dim" converted from git to bzr (including full history) to lp:compiz

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'plugins/dialog'
2=== added file 'plugins/dialog/CMakeLists.txt'
3--- plugins/dialog/CMakeLists.txt 1970-01-01 00:00:00 +0000
4+++ plugins/dialog/CMakeLists.txt 2013-01-09 23:13:24 +0000
5@@ -0,0 +1,5 @@
6+find_package (Compiz REQUIRED)
7+
8+include (CompizPlugin)
9+
10+compiz_plugin (dialog PLUGINDEPS composite opengl)
11
12=== added file 'plugins/dialog/dialog.xml.in'
13--- plugins/dialog/dialog.xml.in 1970-01-01 00:00:00 +0000
14+++ plugins/dialog/dialog.xml.in 2013-01-09 23:13:24 +0000
15@@ -0,0 +1,68 @@
16+<?xml version="1.0"?>
17+<compiz>
18+ <plugin name="dialog" useBcop="true">
19+ <short>Dialog Dim</short>
20+ <long>Fades windows with open dialogs</long>
21+ <category>Extras</category>
22+ <deps>
23+ <relation type="after">
24+ <plugin>composite</plugin>
25+ <plugin>opengl</plugin>
26+ <plugin>decor</plugin>
27+ <plugin>fade</plugin>
28+ </relation>
29+ <requirement>
30+ <plugin>regex</plugin>
31+ <plugin>fade</plugin>
32+ <plugin>opengl</plugin>
33+ </requirement>
34+ </deps>
35+ <options>
36+ <group>
37+ <option name="fading_windows" type="match">
38+ <_short>Fading Windows</_short>
39+ <_long>Windows which are allowed to fade.</_long>
40+ <default>Normal | Dialog | ModalDialog</default>
41+ </option>
42+ <option name="dialogtypes" type="match">
43+ <_short>Dialog Match</_short>
44+ <_long>Dialogs which will trigger fading.</_long>
45+ <default>(override_redirect=0) &amp; !(type=Menu | class=Gimp | class=Inkscape | (class=Firefox &amp; type=Tooltip))</default>
46+ </option>
47+ <option name="speed" type="float">
48+ <_short>Speed</_short>
49+ <_long>The speed of the animation.</_long>
50+ <default>16</default>
51+ <min>1</min>
52+ <max>100</max>
53+ <precision>1</precision>
54+ </option>
55+ <option name="opacity" type="float">
56+ <_short>Opacity</_short>
57+ <_long>The opacity of windows with open dialogs.</_long>
58+ <default>80</default>
59+ <min>0</min>
60+ <max>100</max>
61+ <precision>1</precision>
62+ </option>
63+ <option name="saturation" type="float">
64+ <_short>Saturation</_short>
65+ <_long>The saturation of windows with open dialogs.</_long>
66+ <default>18</default>
67+ <min>0</min>
68+ <max>100</max>
69+ <precision>1</precision>
70+ </option>
71+ <option name="brightness" type="float">
72+ <_short>Brightness</_short>
73+ <_long>The Brightness of windows with open dialogs.</_long>
74+ <default>60</default>
75+ <min>0</min>
76+ <max>100</max>
77+ <precision>1</precision>
78+ </option>
79+ </group>
80+ </options>
81+ </plugin>
82+</compiz>
83+
84
85=== added directory 'plugins/dialog/src'
86=== added file 'plugins/dialog/src/dialog.cpp'
87--- plugins/dialog/src/dialog.cpp 1970-01-01 00:00:00 +0000
88+++ plugins/dialog/src/dialog.cpp 2013-01-09 23:13:24 +0000
89@@ -0,0 +1,158 @@
90+/**
91+ *
92+ * dialog.cpp
93+ *
94+ * Copyright (c) 2008 Douglas Young <rcxdude@gmail.com>
95+ * Input shaping adapted from FreeWins plugin
96+ *
97+ * This program is free software; you can redistribute it and/or
98+ * modify it under the terms of the GNU General Public License
99+ * as published by the Free Software Foundation; either version 2
100+ * of the License, or (at your option) any later version.
101+ *
102+ * This program is distributed in the hope that it will be useful,
103+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
104+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
105+ * GNU General Public License for more details.
106+ *
107+ **/
108+
109+#include "dialog.h"
110+#include <cmath>
111+
112+COMPIZ_PLUGIN_20090315 (dialog, DialogPluginVTable);
113+
114+bool
115+DialogWindow::shouldFade ()
116+{
117+ if (window->overrideRedirect ())
118+ return false;
119+
120+ if (!window->isViewable ())
121+ return false;
122+
123+ if (!DialogScreen::get (screen)->optionGetFadingWindows ().evaluate (window))
124+ return false;
125+
126+ return true;
127+}
128+
129+bool
130+DialogWindow::glPaint (const GLWindowPaintAttrib &attrib,
131+ const GLMatrix &transform,
132+ const CompRegion &region,
133+ unsigned int mask)
134+{
135+ if (mFaded)
136+ {
137+ DIALOG_SCREEN (screen);
138+ GLWindowPaintAttrib wAttrib (attrib);
139+ wAttrib.opacity *= (ds->optionGetOpacity () / 100);
140+ wAttrib.saturation *= (ds->optionGetSaturation () / 100);
141+ wAttrib.brightness *= (ds->optionGetBrightness () / 100);
142+
143+ return gWindow->glPaint (wAttrib, transform, region, mask);
144+ }
145+
146+ return gWindow->glPaint (attrib, transform, region, mask);
147+}
148+
149+void
150+DialogScreen::preparePaint (int ms)
151+{
152+ cScreen->preparePaint (ms);
153+}
154+
155+void
156+DialogScreen::handleEvent (XEvent *event)
157+{
158+ if (event->type == UnmapNotify)
159+ {
160+ CompWindow *w = screen->findWindow (event->xunmap.window);
161+ if (w && w->transientFor ())
162+ {
163+ CompWindow *ww = screen->findWindow (w->transientFor ());
164+ if (ww)
165+ {
166+ DialogWindow *dww = DialogWindow::get (ww);
167+ if (dww->mFaded)
168+ {
169+ int othertrans = 0;
170+ foreach (CompWindow *www, screen->windows ())
171+ {
172+ if (www->transientFor () == ww->id () && w->id () != www->id () &&
173+ optionGetDialogtypes ().evaluate (www))
174+ othertrans++;
175+ }
176+ if (!othertrans)
177+ {
178+ dww->mFaded = false;
179+ CompositeWindow::get (ww)->addDamage ();
180+ }
181+ }
182+ }
183+ }
184+ }
185+ if (event->type == MapNotify)
186+ {
187+ CompWindow *w = screen->findWindow (event->xmap.window);
188+ if (w && w->transientFor () && optionGetDialogtypes ().evaluate (w))
189+ {
190+ CompWindow *ww = screen->findWindow (w->transientFor ());
191+ DialogWindow *dww = DialogWindow::get (ww);
192+ if (!dww->mFaded && dww->shouldFade ())
193+ {
194+ dww->mFaded = true;
195+ dww->cWindow->addDamage ();
196+ }
197+ }
198+ }
199+
200+ screen->handleEvent (event);
201+}
202+
203+void
204+DialogScreen::optionChanged (CompOption *option,
205+ DialogOptions::Options num)
206+{
207+ foreach (CompWindow *w, screen->windows ())
208+ {
209+ DIALOG_WINDOW (w);
210+ dw->cWindow->addDamage ();
211+ }
212+}
213+
214+DialogScreen::DialogScreen (CompScreen *screen) :
215+ PluginClassHandler <DialogScreen, CompScreen> (screen),
216+ cScreen (CompositeScreen::get (screen)),
217+ gScreen (GLScreen::get (screen))
218+{
219+ ScreenInterface::setHandler (screen);
220+ CompositeScreenInterface::setHandler (cScreen);
221+
222+ optionSetOpacityNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
223+ optionSetSaturationNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
224+ optionSetBrightnessNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
225+}
226+
227+DialogWindow::DialogWindow (CompWindow *w) :
228+ PluginClassHandler <DialogWindow, CompWindow> (w),
229+ window (w),
230+ cWindow (CompositeWindow::get (w)),
231+ gWindow (GLWindow::get (w)),
232+ mFaded (false),
233+ mOldTransient (None)
234+{
235+ GLWindowInterface::setHandler (gWindow);
236+}
237+
238+bool
239+DialogPluginVTable::init ()
240+{
241+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
242+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
243+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
244+ return false;
245+
246+ return true;
247+}
248
249=== added file 'plugins/dialog/src/dialog.h'
250--- plugins/dialog/src/dialog.h 1970-01-01 00:00:00 +0000
251+++ plugins/dialog/src/dialog.h 2013-01-09 23:13:24 +0000
252@@ -0,0 +1,101 @@
253+/**
254+ *
255+ * dialog.h
256+ *
257+ * Copyright (c) 2008 Douglas Young <rcxdude@gmail.com>
258+ * Input shaping adapted from FreeWins plugin
259+ *
260+ * This program is free software; you can redistribute it and/or
261+ * modify it under the terms of the GNU General Public License
262+ * as published by the Free Software Foundation; either version 2
263+ * of the License, or (at your option) any later version.
264+ *
265+ * This program is distributed in the hope that it will be useful,
266+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
267+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
268+ * GNU General Public License for more details.
269+ *
270+ **/
271+
272+#include <core/core.h>
273+#include <composite/composite.h>
274+#include <opengl/opengl.h>
275+
276+#include "dialog_options.h"
277+
278+#define ANIMATE_UP 1
279+#define ANIMATE_DOWN 2
280+#define ANIMATE_NONE 0
281+
282+class DialogScreen :
283+ public PluginClassHandler <DialogScreen, CompScreen>,
284+ public ScreenInterface,
285+ public CompositeScreenInterface,
286+ public DialogOptions
287+{
288+ public:
289+
290+ DialogScreen (CompScreen *s);
291+
292+ public:
293+
294+ CompositeScreen *cScreen;
295+ GLScreen *gScreen;
296+
297+ void
298+ preparePaint (int);
299+
300+ void
301+ handleEvent (XEvent *);
302+
303+ void
304+ optionChanged (CompOption *opt,
305+ DialogOptions::Options);
306+};
307+
308+class DialogWindow :
309+ public PluginClassHandler <DialogWindow, CompWindow>,
310+ public GLWindowInterface
311+{
312+ public:
313+
314+ DialogWindow (CompWindow *);
315+
316+ public:
317+
318+ CompWindow *window;
319+ CompositeWindow *cWindow;
320+ GLWindow *gWindow;
321+ bool mFaded;
322+
323+ Window mOldTransient;
324+
325+ bool shouldFade ();
326+
327+ bool
328+ glPaint (const GLWindowPaintAttrib &,
329+ const GLMatrix &,
330+ const CompRegion &,
331+ unsigned int );
332+};
333+
334+#define DIALOG_SCREEN(s) \
335+ DialogScreen *ds = DialogScreen::get (s);
336+
337+#define DIALOG_WINDOW(w) \
338+ DialogWindow *dw = DialogWindow::get (w);
339+
340+#define WIN_X(w) ((w)->x () - (w)->border ().left)
341+#define WIN_Y(w) ((w)->y () - (w)->border ().top)
342+#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
343+#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)
344+
345+#define SPEED (optionGetSpeed () * 0.0005f)
346+
347+class DialogPluginVTable :
348+ public CompPlugin::VTableForScreenAndWindow <DialogScreen, DialogWindow>
349+{
350+ public:
351+
352+ bool init ();
353+};

Subscribers

People subscribed via source and target branches