aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh')
-rw-r--r--util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh144
1 files changed, 144 insertions, 0 deletions
diff --git a/util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh b/util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh
new file mode 100644
index 0000000..bd3d07c
--- /dev/null
+++ b/util/fbcompose/plugins/opengl/preview/PreviewPlugin.hh
@@ -0,0 +1,144 @@
1/** PreviewPlugin.hh file for the fluxbox compositor. */
2
3// Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23
24#ifndef FBCOMPOSITOR_PLUGIN_OPENGL_PREVIEW_PREVIEWPLUGIN_HH
25#define FBCOMPOSITOR_PLUGIN_OPENGL_PREVIEW_PREVIEWPLUGIN_HH
26
27
28#include "Enumerations.hh"
29#include "OpenGLPlugin.hh"
30#include "OpenGLResources.hh"
31#include "OpenGLShaders.hh"
32#include "TickTracker.hh"
33
34#include "FbTk/FbString.hh"
35
36#include <GL/glew.h>
37#include <GL/gl.h>
38
39#include <X11/Xlib.h>
40
41#include <map>
42#include <vector>
43
44
45namespace FbCompositor {
46
47 class BaseScreen;
48 class OpenGLScreen;
49 class OpenGLWindow;
50
51
52 /**
53 * Provides window preview feature for the iconbar.
54 */
55 class PreviewPlugin : public OpenGLPlugin {
56 struct PreviewWindowData;
57
58 public :
59 //--- CONSTRUCTORS AND DESTRUCTORS -------------------------------------
60
61 /** Constructor. */
62 PreviewPlugin(const BaseScreen &screen, const std::vector<FbTk::FbString> &args);
63
64 /** Destructor. */
65 ~PreviewPlugin();
66
67
68 //--- ACCESSORS --------------------------------------------------------
69
70 /** \returns the name of the plugin. */
71 const char *pluginName() const;
72
73
74 /** \returns the additional source code for the fragment shader. */
75 const char *fragmentShader() const;
76
77 /** \returns the additional source code for the vertex shader. */
78 const char *vertexShader() const;
79
80
81 //--- WINDOW EVENT CALLBACKS -------------------------------------------
82
83 /** Called, whenever a new window is created. */
84 void windowCreated(const BaseCompWindow &window);
85
86 /** Called, whenever a window is destroyed. */
87 void windowDestroyed(const BaseCompWindow &window);
88
89
90 //--- RENDERING ACTIONS ------------------------------------------------
91
92 /** Extra rendering actions and jobs. */
93 const std::vector<OpenGLRenderingJob> &extraRenderingActions();
94
95
96 private :
97 //--- INTERNAL FUNCTIONS -----------------------------------------------
98
99 /** Update the preview window. */
100 void updatePreviewWindow(PreviewWindowData &win_preview);
101
102
103 //--- GENERAL RENDERING VARIABLES --------------------------------------
104
105 /** Vector, containing the plugin's extra rendering jobs. */
106 std::vector<OpenGLRenderingJob> m_extra_jobs;
107
108
109 /** Timer that signals when the preview window should appear. */
110 TickTracker m_tick_tracker;
111
112
113 //--- PREVIEW WINDOW DATA ----------------------------------------------
114
115 /** Holds data about the preview window. */
116 struct PreviewWindowData {
117 const OpenGLWindow &window; ///< The corresponding window object.
118 OpenGLRenderingJob job; ///< Rendering job of this preview object.
119 };
120
121 /** A list of potential preview windows. */
122 std::map<Window, PreviewWindowData> m_preview_data;
123 };
124
125
126 //--- INLINE FUNCTIONS -----------------------------------------------------
127
128 // Returns the name of the plugin.
129 inline const char *PreviewPlugin::pluginName() const {
130 return "preview";
131 }
132}
133
134
135//--- PLUGIN MANAGER FUNCTIONS -------------------------------------------------
136
137/** Creates a plugin object. */
138extern "C" FbCompositor::BasePlugin *createPlugin(const FbCompositor::BaseScreen &screen, const std::vector<FbTk::FbString> &args);
139
140/** \returns the type of the plugin. */
141extern "C" FbCompositor::PluginType pluginType();
142
143
144#endif // FBCOMPOSITOR_PLUGIN_OPENGL_PREVIEW_PREVIEWPLUGIN_HH