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

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz0.9.9.merge-plugin-dialog
Merge into: lp:compiz/0.9.11
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 Pending
Review via email: mp+176735@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

Note:
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

Merged latest lp:compiz

3292. By MC Return

Reverted last commit and fixed the right typo this time

3291. By MC Return

Fixed typo

3290. By MC Return

Fixed a few of the tooltips

3289. By MC Return

Hopefully fixed indentation

3288. By MC Return

Removed plugins/dialog/VERSION

3287. By MC Return

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
=== added directory 'plugins/dialog'
=== added file 'plugins/dialog/CMakeLists.txt'
--- plugins/dialog/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/dialog/CMakeLists.txt 2013-07-24 16:23:29 +0000
@@ -0,0 +1,5 @@
1find_package (Compiz REQUIRED)
2
3include (CompizPlugin)
4
5compiz_plugin (dialog PLUGINDEPS composite opengl)
06
=== added file 'plugins/dialog/dialog.xml.in'
--- plugins/dialog/dialog.xml.in 1970-01-01 00:00:00 +0000
+++ plugins/dialog/dialog.xml.in 2013-07-24 16:23:29 +0000
@@ -0,0 +1,68 @@
1<?xml version="1.0"?>
2<compiz>
3 <plugin name="dialog" useBcop="true">
4 <short>Dialog Dim</short>
5 <long>Fades windows with open dialogs</long>
6 <category>Extras</category>
7 <deps>
8 <relation type="after">
9 <plugin>composite</plugin>
10 <plugin>opengl</plugin>
11 <plugin>decor</plugin>
12 <plugin>fade</plugin>
13 </relation>
14 <requirement>
15 <plugin>regex</plugin>
16 <plugin>fade</plugin>
17 <plugin>opengl</plugin>
18 </requirement>
19 </deps>
20 <options>
21 <group>
22 <option name="fading_windows" type="match">
23 <_short>Fading Windows</_short>
24 <_long>Windows which are allowed to fade.</_long>
25 <default>Normal | Dialog | ModalDialog</default>
26 </option>
27 <option name="dialogtypes" type="match">
28 <_short>Dialog Match</_short>
29 <_long>Dialogs which will trigger fading.</_long>
30 <default>(override_redirect=0) &amp; !(type=Menu | class=Gimp | class=Inkscape | (class=Firefox &amp; type=Tooltip))</default>
31 </option>
32 <option name="speed" type="float">
33 <_short>Speed</_short>
34 <_long>The speed of the animation.</_long>
35 <default>16</default>
36 <min>1</min>
37 <max>100</max>
38 <precision>1</precision>
39 </option>
40 <option name="opacity" type="float">
41 <_short>Opacity</_short>
42 <_long>The opacity of windows with open dialogs.</_long>
43 <default>80</default>
44 <min>0</min>
45 <max>100</max>
46 <precision>1</precision>
47 </option>
48 <option name="saturation" type="float">
49 <_short>Saturation</_short>
50 <_long>The saturation of windows with open dialogs.</_long>
51 <default>18</default>
52 <min>0</min>
53 <max>100</max>
54 <precision>1</precision>
55 </option>
56 <option name="brightness" type="float">
57 <_short>Brightness</_short>
58 <_long>The Brightness of windows with open dialogs.</_long>
59 <default>60</default>
60 <min>0</min>
61 <max>100</max>
62 <precision>1</precision>
63 </option>
64 </group>
65 </options>
66 </plugin>
67</compiz>
68
069
=== added directory 'plugins/dialog/src'
=== added file 'plugins/dialog/src/dialog.cpp'
--- plugins/dialog/src/dialog.cpp 1970-01-01 00:00:00 +0000
+++ plugins/dialog/src/dialog.cpp 2013-07-24 16:23:29 +0000
@@ -0,0 +1,158 @@
1/**
2 *
3 * dialog.cpp
4 *
5 * Copyright (c) 2008 Douglas Young <rcxdude@gmail.com>
6 * Input shaping adapted from FreeWins plugin
7 *
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.
12 *
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.
17 *
18 **/
19
20#include "dialog.h"
21#include <cmath>
22
23COMPIZ_PLUGIN_20090315 (dialog, DialogPluginVTable);
24
25bool
26DialogWindow::shouldFade ()
27{
28 if (window->overrideRedirect ())
29 return false;
30
31 if (!window->isViewable ())
32 return false;
33
34 if (!DialogScreen::get (screen)->optionGetFadingWindows ().evaluate (window))
35 return false;
36
37 return true;
38}
39
40bool
41DialogWindow::glPaint (const GLWindowPaintAttrib &attrib,
42 const GLMatrix &transform,
43 const CompRegion &region,
44 unsigned int mask)
45{
46 if (mFaded)
47 {
48 DIALOG_SCREEN (screen);
49 GLWindowPaintAttrib wAttrib (attrib);
50 wAttrib.opacity *= (ds->optionGetOpacity () / 100);
51 wAttrib.saturation *= (ds->optionGetSaturation () / 100);
52 wAttrib.brightness *= (ds->optionGetBrightness () / 100);
53
54 return gWindow->glPaint (wAttrib, transform, region, mask);
55 }
56
57 return gWindow->glPaint (attrib, transform, region, mask);
58}
59
60void
61DialogScreen::preparePaint (int ms)
62{
63 cScreen->preparePaint (ms);
64}
65
66void
67DialogScreen::handleEvent (XEvent *event)
68{
69 if (event->type == UnmapNotify)
70 {
71 CompWindow *w = screen->findWindow (event->xunmap.window);
72 if (w && w->transientFor ())
73 {
74 CompWindow *ww = screen->findWindow (w->transientFor ());
75 if (ww)
76 {
77 DialogWindow *dww = DialogWindow::get (ww);
78 if (dww->mFaded)
79 {
80 int othertrans = 0;
81 foreach (CompWindow *www, screen->windows ())
82 {
83 if (www->transientFor () == ww->id () && w->id () != www->id () &&
84 optionGetDialogtypes ().evaluate (www))
85 othertrans++;
86 }
87 if (!othertrans)
88 {
89 dww->mFaded = false;
90 CompositeWindow::get (ww)->addDamage ();
91 }
92 }
93 }
94 }
95 }
96 if (event->type == MapNotify)
97 {
98 CompWindow *w = screen->findWindow (event->xmap.window);
99 if (w && w->transientFor () && optionGetDialogtypes ().evaluate (w))
100 {
101 CompWindow *ww = screen->findWindow (w->transientFor ());
102 DialogWindow *dww = DialogWindow::get (ww);
103 if (!dww->mFaded && dww->shouldFade ())
104 {
105 dww->mFaded = true;
106 dww->cWindow->addDamage ();
107 }
108 }
109 }
110
111 screen->handleEvent (event);
112}
113
114void
115DialogScreen::optionChanged (CompOption *option,
116 DialogOptions::Options num)
117{
118 foreach (CompWindow *w, screen->windows ())
119 {
120 DIALOG_WINDOW (w);
121 dw->cWindow->addDamage ();
122 }
123}
124
125DialogScreen::DialogScreen (CompScreen *screen) :
126 PluginClassHandler <DialogScreen, CompScreen> (screen),
127 cScreen (CompositeScreen::get (screen)),
128 gScreen (GLScreen::get (screen))
129{
130 ScreenInterface::setHandler (screen);
131 CompositeScreenInterface::setHandler (cScreen);
132
133 optionSetOpacityNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
134 optionSetSaturationNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
135 optionSetBrightnessNotify (boost::bind (&DialogScreen::optionChanged, this, _1, _2));
136}
137
138DialogWindow::DialogWindow (CompWindow *w) :
139 PluginClassHandler <DialogWindow, CompWindow> (w),
140 window (w),
141 cWindow (CompositeWindow::get (w)),
142 gWindow (GLWindow::get (w)),
143 mFaded (false),
144 mOldTransient (None)
145{
146 GLWindowInterface::setHandler (gWindow);
147}
148
149bool
150DialogPluginVTable::init ()
151{
152 if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
153 !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
154 !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
155 return false;
156
157 return true;
158}
0159
=== added file 'plugins/dialog/src/dialog.h'
--- plugins/dialog/src/dialog.h 1970-01-01 00:00:00 +0000
+++ plugins/dialog/src/dialog.h 2013-07-24 16:23:29 +0000
@@ -0,0 +1,101 @@
1/**
2 *
3 * dialog.h
4 *
5 * Copyright (c) 2008 Douglas Young <rcxdude@gmail.com>
6 * Input shaping adapted from FreeWins plugin
7 *
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.
12 *
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.
17 *
18 **/
19
20#include <core/core.h>
21#include <composite/composite.h>
22#include <opengl/opengl.h>
23
24#include "dialog_options.h"
25
26#define ANIMATE_UP 1
27#define ANIMATE_DOWN 2
28#define ANIMATE_NONE 0
29
30class DialogScreen :
31 public PluginClassHandler <DialogScreen, CompScreen>,
32 public ScreenInterface,
33 public CompositeScreenInterface,
34 public DialogOptions
35{
36 public:
37
38 DialogScreen (CompScreen *s);
39
40 public:
41
42 CompositeScreen *cScreen;
43 GLScreen *gScreen;
44
45 void
46 preparePaint (int);
47
48 void
49 handleEvent (XEvent *);
50
51 void
52 optionChanged (CompOption *opt,
53 DialogOptions::Options);
54};
55
56class DialogWindow :
57 public PluginClassHandler <DialogWindow, CompWindow>,
58 public GLWindowInterface
59{
60 public:
61
62 DialogWindow (CompWindow *);
63
64 public:
65
66 CompWindow *window;
67 CompositeWindow *cWindow;
68 GLWindow *gWindow;
69 bool mFaded;
70
71 Window mOldTransient;
72
73 bool shouldFade ();
74
75 bool
76 glPaint (const GLWindowPaintAttrib &,
77 const GLMatrix &,
78 const CompRegion &,
79 unsigned int );
80};
81
82#define DIALOG_SCREEN(s) \
83 DialogScreen *ds = DialogScreen::get (s);
84
85#define DIALOG_WINDOW(w) \
86 DialogWindow *dw = DialogWindow::get (w);
87
88#define WIN_X(w) ((w)->x () - (w)->border ().left)
89#define WIN_Y(w) ((w)->y () - (w)->border ().top)
90#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
91#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)
92
93#define SPEED (optionGetSpeed () * 0.0005f)
94
95class DialogPluginVTable :
96 public CompPlugin::VTableForScreenAndWindow <DialogScreen, DialogWindow>
97{
98 public:
99
100 bool init ();
101};

Subscribers

People subscribed via source and target branches

to all changes: