~vanvugt/compiz-plugins-main/fix-915236

« back to all changes in this revision

Viewing changes to text/src/private.h

  • Committer: Sam Spilsbury
  • Date: 2011-08-04 16:31:54 UTC
  • Revision ID: sam.spilsbury@canonical.com-20110804163154-ys9vvppcvh3k8ay7
Sync in changes from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz text plugin
 
3
 * Description: Adds text to pixmap support to Compiz.
 
4
 *
 
5
 * private.h
 
6
 *
 
7
 * Copyright: (C) 2006-2007 Patrick Niklaus, Danny Baumann, Dennis Kasprzyk
 
8
 * Authors: Patrick Niklaus <marex@opencompsiting.org>
 
9
 *          Danny Baumann   <maniac@opencompositing.org>
 
10
 *          Dennis Kasprzyk <onestone@opencompositing.org>
 
11
 *
 
12
 * This program is free software; you can redistribute it and/or
 
13
 * modify it under the terms of the GNU General Public License
 
14
 * as published by the Free Software Foundation; either version 2
 
15
 * of the License, or (at your option) any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; if not, write to the Free Software
 
24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
25
 *
 
26
 */
 
27
 
 
28
#include <core/core.h>
 
29
#include <core/pluginclasshandler.h>
 
30
#include <composite/composite.h>
 
31
#include <opengl/opengl.h>
 
32
 
 
33
#include <cairo-xlib-xrender.h>
 
34
#include <pango/pango.h>
 
35
#include <pango/pangocairo.h>
 
36
 
 
37
#include <X11/Xatom.h>
 
38
 
 
39
#include <text/text.h>
 
40
 
 
41
class PrivateTextScreen :
 
42
    public PluginClassHandler <PrivateTextScreen, CompScreen, COMPIZ_TEXT_ABI>,
 
43
    public ScreenInterface,
 
44
    public GLScreenInterface
 
45
{
 
46
    public:
 
47
 
 
48
        PrivateTextScreen (CompScreen *);
 
49
        ~PrivateTextScreen ();
 
50
 
 
51
        CompString getWindowName (Window id);
 
52
 
 
53
        GLScreen *gScreen;
 
54
 
 
55
    private:
 
56
        Atom visibleNameAtom;
 
57
        Atom utf8StringAtom;
 
58
        Atom wmNameAtom;
 
59
 
 
60
        CompString getUtf8Property (Window id, Atom atom);
 
61
        CompString getTextProperty (Window id, Atom atom);
 
62
};
 
63
 
 
64
class TextSurface
 
65
{
 
66
    public:
 
67
        TextSurface  ();
 
68
        ~TextSurface ();
 
69
 
 
70
        bool valid () const;
 
71
 
 
72
        bool render (const CompText::Attrib &attrib,
 
73
                     const CompString       &text);
 
74
 
 
75
        int          mWidth;
 
76
        int          mHeight;
 
77
        Pixmap       mPixmap;
 
78
 
 
79
    private:
 
80
        bool initCairo (int w,
 
81
                        int h);
 
82
        bool update (int w,
 
83
                     int h);
 
84
        void drawBackground (int x, int y,
 
85
                             int width, int height,
 
86
                             int radius);
 
87
 
 
88
        cairo_t              *cr;
 
89
        cairo_surface_t      *surface;
 
90
        PangoLayout          *layout;
 
91
        XRenderPictFormat    *format;
 
92
        PangoFontDescription *font;
 
93
        Screen               *scrn;
 
94
};
 
95
 
 
96
#define TEXT_SCREEN(screen)                                                   \
 
97
    PrivateTextScreen *ts = PrivateTextScreen::get (screen);
 
98
 
 
99
class TextPluginVTable :
 
100
    public CompPlugin::VTableForScreen <PrivateTextScreen>
 
101
{
 
102
    public:
 
103
 
 
104
        bool init ();
 
105
        void fini ();
 
106
};