Merge lp:~mc-return/compiz/compiz.merge-plugin-workspacenames into lp:compiz/0.9.8

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3248
Merged at revision: 3248
Proposed branch: lp:~mc-return/compiz/compiz.merge-plugin-workspacenames
Merge into: lp:compiz/0.9.8
Diff against target: 481 lines (+460/-0)
4 files modified
plugins/workspacenames/CMakeLists.txt (+5/-0)
plugins/workspacenames/src/workspacenames.cpp (+250/-0)
plugins/workspacenames/src/workspacenames.h (+91/-0)
plugins/workspacenames/workspacenames.xml.in (+114/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-plugin-workspacenames
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Review via email: mp+110485@code.launchpad.net

Commit message

Added the unsupported, but fully working plug-in "workspacenames" converted from git to bzr (including history) to Compiz 0.9.8.

Description of the change

Adds the unsupported, but fully working plug-in "workspacenames" converted from git to bzr (including history) to Compiz 0.9.8.

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote :

This one should work now :)

Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'plugins/workspacenames'
2=== added file 'plugins/workspacenames/CMakeLists.txt'
3--- plugins/workspacenames/CMakeLists.txt 1970-01-01 00:00:00 +0000
4+++ plugins/workspacenames/CMakeLists.txt 2012-06-15 08:14:21 +0000
5@@ -0,0 +1,5 @@
6+find_package (Compiz REQUIRED)
7+
8+include (CompizPlugin)
9+
10+compiz_plugin (workspacenames PLUGINDEPS composite opengl text)
11
12=== added directory 'plugins/workspacenames/src'
13=== added file 'plugins/workspacenames/src/workspacenames.cpp'
14--- plugins/workspacenames/src/workspacenames.cpp 1970-01-01 00:00:00 +0000
15+++ plugins/workspacenames/src/workspacenames.cpp 2012-06-15 08:14:21 +0000
16@@ -0,0 +1,250 @@
17+/*
18+ *
19+ * Compiz workspace name display plugin
20+ *
21+ * workspacenames.cpp
22+ *
23+ * Copyright : (C) 2008 by Danny Baumann
24+ * E-mail : maniac@compiz-fusion.org
25+ *
26+ * Ported to Compiz 0.9.x
27+ * Copyright : (c) 2010 Scott Moreau <oreaus@gmail.com>
28+ *
29+ * This program is free software; you can redistribute it and/or
30+ * modify it under the terms of the GNU General Public License
31+ * as published by the Free Software Foundation; either version 2
32+ * of the License, or (at your option) any later version.
33+ *
34+ * This program is distributed in the hope that it will be useful,
35+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37+ * GNU General Public License for more details.
38+ *
39+ */
40+
41+#include "workspacenames.h"
42+
43+CompString
44+WSNamesScreen::getCurrentWSName ()
45+{
46+ int currentVp;
47+ int listSize, i;
48+ CompString ret;
49+ CompOption::Value::Vector names;
50+ CompOption::Value::Vector vpNumbers;
51+
52+ vpNumbers = optionGetViewports ();
53+ names = optionGetNames ();
54+
55+ currentVp = screen->vp ().y () * screen->vpSize ().width () +
56+ screen->vp ().x () + 1;
57+ listSize = MIN (vpNumbers.size (), names.size ());
58+
59+ for (i = 0; i < listSize; i++)
60+ if (vpNumbers[i].i () == currentVp)
61+ return names[i].s ();
62+
63+ return ret;
64+}
65+
66+void
67+WSNamesScreen::renderNameText ()
68+{
69+ CompText::Attrib attrib;
70+ CompString name;
71+
72+ textData.clear ();
73+
74+ name = getCurrentWSName ();
75+
76+ if (name.empty ())
77+ return;
78+
79+ /* 75% of the output device as maximum width */
80+ attrib.maxWidth = screen->getCurrentOutputExtents ().width () * 3 / 4;
81+ attrib.maxHeight = 100;
82+
83+ attrib.family = "Sans";
84+ attrib.size = optionGetTextFontSize ();
85+
86+ attrib.color[0] = optionGetFontColorRed ();
87+ attrib.color[1] = optionGetFontColorGreen ();
88+ attrib.color[2] = optionGetFontColorBlue ();
89+ attrib.color[3] = optionGetFontColorAlpha ();
90+
91+ attrib.flags = CompText::WithBackground | CompText::Ellipsized;
92+ if (optionGetBoldText ())
93+ attrib.flags |= CompText::StyleBold;
94+
95+ attrib.bgHMargin = 15;
96+ attrib.bgVMargin = 15;
97+ attrib.bgColor[0] = optionGetBackColorRed ();
98+ attrib.bgColor[1] = optionGetBackColorGreen ();
99+ attrib.bgColor[2] = optionGetBackColorBlue ();
100+ attrib.bgColor[3] = optionGetBackColorAlpha ();
101+
102+ textData.renderText (name, attrib);
103+}
104+
105+void
106+WSNamesScreen::drawText ()
107+{
108+ GLfloat alpha;
109+ float x, y, border = 10.0f;
110+ CompRect oe = screen->getCurrentOutputExtents ();
111+
112+ x = oe.centerX () - textData.getWidth () / 2;
113+
114+ /* assign y (for the lower corner!) according to the setting */
115+ switch (optionGetTextPlacement ())
116+ {
117+ case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
118+ y = oe.centerY () + textData.getHeight () / 2;
119+ break;
120+ case WorkspacenamesOptions::TextPlacementTopOfScreen:
121+ case WorkspacenamesOptions::TextPlacementBottomOfScreen:
122+ {
123+ CompRect workArea = screen->currentOutputDev ().workArea ();
124+
125+ if (optionGetTextPlacement () ==
126+ WorkspacenamesOptions::TextPlacementTopOfScreen)
127+ y = oe.y1 () + workArea.y () +
128+ (2 * border) + textData.getHeight ();
129+ else
130+ y = oe.y1 () + workArea.y () +
131+ workArea.height () - (2 * border);
132+ }
133+ break;
134+ default:
135+ return;
136+ break;
137+ }
138+
139+ if (timer)
140+ alpha = timer / (optionGetFadeTime () * 1000.0f);
141+ else
142+ alpha = 1.0f;
143+
144+ textData.draw (floor (x), floor (y), alpha);
145+}
146+
147+bool
148+WSNamesScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
149+ const GLMatrix &transform,
150+ const CompRegion &region,
151+ CompOutput *output,
152+ unsigned int mask)
153+{
154+ bool status;
155+
156+ status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
157+
158+ if (textData.getWidth () && textData.getHeight ())
159+ {
160+ GLMatrix sTransform (transform);
161+
162+ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
163+ glPushMatrix ();
164+ glLoadMatrixf (sTransform.getMatrix ());
165+
166+ drawText ();
167+
168+ glPopMatrix ();
169+ }
170+
171+ return status;
172+}
173+
174+void
175+WSNamesScreen::preparePaint (int msSinceLastPaint)
176+{
177+ if (timer)
178+ {
179+ timer -= msSinceLastPaint;
180+ timer = MAX (timer, 0);
181+
182+ if (!timer)
183+ textData.clear ();
184+ }
185+
186+ cScreen->preparePaint (msSinceLastPaint);
187+}
188+
189+void
190+WSNamesScreen::donePaint ()
191+{
192+ /* FIXME: better only damage paint region */
193+ if (timer)
194+ cScreen->damageScreen ();
195+
196+ cScreen->donePaint ();
197+}
198+
199+bool
200+WSNamesScreen::hideTimeout ()
201+{
202+ timer = optionGetFadeTime () * 1000;
203+ if (!timer)
204+ textData.clear ();
205+
206+ cScreen->damageScreen ();
207+
208+ timeoutHandle.stop ();
209+
210+ return false;
211+}
212+
213+void
214+WSNamesScreen::handleEvent (XEvent *event)
215+{
216+ screen->handleEvent (event);
217+
218+ if (event->type != PropertyNotify)
219+ return;
220+
221+ if (event->xproperty.atom == Atoms::desktopViewport)
222+ {
223+ int timeout = optionGetDisplayTime () * 1000;
224+
225+ timer = 0;
226+ if (timeoutHandle.active ())
227+ timeoutHandle.stop ();
228+
229+ renderNameText ();
230+ timeoutHandle.start (timeout, timeout + 200);
231+
232+ cScreen->damageScreen ();
233+ }
234+}
235+
236+WSNamesScreen::WSNamesScreen (CompScreen *screen) :
237+ PluginClassHandler <WSNamesScreen, CompScreen> (screen),
238+ cScreen (CompositeScreen::get (screen)),
239+ gScreen (GLScreen::get (screen)),
240+ timer (0)
241+{
242+ ScreenInterface::setHandler (screen, true);
243+ CompositeScreenInterface::setHandler (cScreen, true);
244+ GLScreenInterface::setHandler (gScreen, true);
245+
246+ timeoutHandle.start (boost::bind (&WSNamesScreen::hideTimeout, this),
247+ 0, 0);
248+}
249+
250+WSNamesScreen::~WSNamesScreen ()
251+{
252+}
253+
254+bool
255+WorkspacenamesPluginVTable::init ()
256+{
257+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
258+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
259+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
260+ return false;
261+
262+ if (!CompPlugin::checkPluginABI ("text", COMPIZ_TEXT_ABI))
263+ compLogMessage ("workspacenames", CompLogLevelWarn,
264+ "No compatible text plugin loaded");
265+ return true;
266+}
267
268=== added file 'plugins/workspacenames/src/workspacenames.h'
269--- plugins/workspacenames/src/workspacenames.h 1970-01-01 00:00:00 +0000
270+++ plugins/workspacenames/src/workspacenames.h 2012-06-15 08:14:21 +0000
271@@ -0,0 +1,91 @@
272+/*
273+ *
274+ * Compiz workspace name display plugin
275+ *
276+ * workspacenames.h
277+ *
278+ * Copyright : (C) 2008 by Danny Baumann
279+ * E-mail : maniac@compiz-fusion.org
280+ *
281+ * Ported to Compiz 0.9.x
282+ * Copyright : (c) 2010 Scott Moreau <oreaus@gmail.com>
283+ *
284+ * This program is free software; you can redistribute it and/or
285+ * modify it under the terms of the GNU General Public License
286+ * as published by the Free Software Foundation; either version 2
287+ * of the License, or (at your option) any later version.
288+ *
289+ * This program is distributed in the hope that it will be useful,
290+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
291+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
292+ * GNU General Public License for more details.
293+ *
294+ */
295+
296+#include <stdio.h>
297+#include <stdlib.h>
298+#include <math.h>
299+
300+#include <core/core.h>
301+#include <core/atoms.h>
302+#include <composite/composite.h>
303+#include <opengl/opengl.h>
304+#include <text/text.h>
305+
306+#include "workspacenames_options.h"
307+
308+class WSNamesScreen :
309+ public PluginClassHandler <WSNamesScreen, CompScreen>,
310+ public ScreenInterface,
311+ public CompositeScreenInterface,
312+ public GLScreenInterface,
313+ public WorkspacenamesOptions
314+{
315+ public:
316+ WSNamesScreen (CompScreen *screen);
317+ ~WSNamesScreen ();
318+
319+ CompositeScreen *cScreen;
320+ GLScreen *gScreen;
321+
322+ CompText textData;
323+ CompTimer timeoutHandle;
324+ int timer;
325+
326+ CompString
327+ getCurrentWSName ();
328+
329+ void
330+ renderNameText ();
331+
332+ void
333+ drawText ();
334+
335+ bool
336+ glPaintOutput (const GLScreenPaintAttrib &attrib,
337+ const GLMatrix &transform,
338+ const CompRegion &region,
339+ CompOutput *output,
340+ unsigned int mask);
341+
342+ void
343+ preparePaint (int ms);
344+
345+ void
346+ donePaint ();
347+
348+ bool
349+ hideTimeout ();
350+
351+ void
352+ handleEvent (XEvent *);
353+};
354+
355+class WorkspacenamesPluginVTable :
356+ public CompPlugin::VTableForScreen <WSNamesScreen>
357+{
358+ public:
359+ bool init ();
360+};
361+
362+COMPIZ_PLUGIN_20090315 (workspacenames, WorkspacenamesPluginVTable);
363
364=== added file 'plugins/workspacenames/workspacenames.xml.in'
365--- plugins/workspacenames/workspacenames.xml.in 1970-01-01 00:00:00 +0000
366+++ plugins/workspacenames/workspacenames.xml.in 2012-06-15 08:14:21 +0000
367@@ -0,0 +1,114 @@
368+<?xml version="1.0"?>
369+<compiz>
370+ <plugin name="workspacenames" useBcop="true">
371+ <_short>Workspace Naming</_short>
372+ <_long>Allows assigning descriptions to workspaces</_long>
373+ <category>Window Management</category>
374+ <deps>
375+ <relation type="after">
376+ <plugin>opengl</plugin>
377+ <plugin>composite</plugin>
378+ <plugin>text</plugin>
379+ </relation>
380+ <requirement>
381+ <plugin>opengl</plugin>
382+ </requirement>
383+ </deps>
384+ <options>
385+ <group>
386+ <_short>Names</_short>
387+ <subgroup>
388+ <_short>Workspace Names</_short>
389+ <option name="viewports" type="list">
390+ <_short>Viewport</_short>
391+ <_long>Number of viewport to be named</_long>
392+ <type>int</type>
393+ <min>1</min>
394+ <max>50</max>
395+ </option>
396+ <option name="names" type="list">
397+ <_short>Name</_short>
398+ <_long>Viewport name</_long>
399+ <type>string</type>
400+ </option>
401+ </subgroup>
402+ </group>
403+ <group>
404+ <_short>Appearance</_short>
405+ <option name="display_time" type="float">
406+ <_short>Display Time</_short>
407+ <_long>Timeout (in s) of the name display</_long>
408+ <min>0.1</min>
409+ <max>5.0</max>
410+ <precision>0.05</precision>
411+ <default>0.5</default>
412+ </option>
413+ <option name="fade_time" type="float">
414+ <_short>Fade Time</_short>
415+ <_long>Time (in s) the name display fades out after being shown.</_long>
416+ <min>0.0</min>
417+ <max>5.0</max>
418+ <precision>0.05</precision>
419+ <default>0.25</default>
420+ </option>
421+ <subgroup>
422+ <_short>Text Display</_short>
423+ <option name="bold_text" type="bool">
424+ <_short>Bold Font</_short>
425+ <_long>Selects if the text should be displayed in bold font or not.</_long>
426+ <default>false</default>
427+ </option>
428+ <option name="text_font_size" type="int">
429+ <_short>Font Size</_short>
430+ <_long>Font size for the text display.</_long>
431+ <default>16</default>
432+ <min>6</min>
433+ <max>96</max>
434+ </option>
435+ <option name="text_placement" type="int">
436+ <_short>Text Placement</_short>
437+ <_long>Selects where to place the text.</_long>
438+ <default>0</default>
439+ <min>0</min>
440+ <max>2</max>
441+ <desc>
442+ <value>0</value>
443+ <_name>Centered on screen</_name>
444+ </desc>
445+ <desc>
446+ <value>1</value>
447+ <_name>Top of screen</_name>
448+ </desc>
449+ <desc>
450+ <value>2</value>
451+ <_name>Bottom of screen</_name>
452+ </desc>
453+ </option>
454+ </subgroup>
455+ <subgroup>
456+ <_short>Colors</_short>
457+ <option name="back_color" type="color">
458+ <_short>Background Color</_short>
459+ <_long>Background color for the text display.</_long>
460+ <default>
461+ <red>0x0000</red>
462+ <green>0x0000</green>
463+ <blue>0x0000</blue>
464+ <alpha>0x9999</alpha>
465+ </default>
466+ </option>
467+ <option name="font_color" type="color">
468+ <_short>Font Color</_short>
469+ <_long>Font color for the text display.</_long>
470+ <default>
471+ <red>0xffff</red>
472+ <green>0xffff</green>
473+ <blue>0xffff</blue>
474+ <alpha>0xffff</alpha>
475+ </default>
476+ </option>
477+ </subgroup>
478+ </group>
479+ </options>
480+ </plugin>
481+</compiz>

Subscribers

People subscribed via source and target branches