~ubuntu-branches/ubuntu/trusty/kdeplasma-addons/trusty

« back to all changes in this revision

Viewing changes to applets/lancelot/app/src/QtDisplay.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 09:50:14 UTC
  • mfrom: (1.1.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525095014-6mlrm9z9bkws0zkt
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest build-dep version to 4.4.80
  - Refresh kubuntu_04_kimpanel_disable_scim.diff
  - Update various .install files
  - Drop liblancelot0a and liblancelot-dev packages; Upstream has broken ABI
    without an .so version bump, and after discussion with Debian it was
    decided it was not worth it to ship an unstable library.
  - Add liblancelot files to plasma-widget-lancelot, adding appropriate
    Replaces: entries
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright (C) 2005,2006,2007 by Siraj Razick <siraj@kde.org>
3
 
 *
4
 
 *   This program is free software; you can redistribute it and/or modify
5
 
 *   it under the terms of the GNU General Public License version 2,
6
 
 *   or (at your option) any later version, as published by the Free
7
 
 *   Software Foundation
8
 
 *
9
 
 *   This program is distributed in the hope that it will be useful,
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *   GNU General Public License for more details
13
 
 *
14
 
 *   You should have received a copy of the GNU General Public
15
 
 *   License along with this program; if not, write to the
16
 
 *   Free Software Foundation, Inc.,
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 */
19
 
 
20
 
#include "QtDisplay.h"
21
 
 
22
 
#include <config-lancelot.h>
23
 
 
24
 
#ifdef LANCELOT_HAVE_COMPOSITING
25
 
 
26
 
QtDisplay::QtDisplay(char * display, int screen)
27
 
{
28
 
    _displayPtr = display;
29
 
    _screen = screen;
30
 
    _alpha = 0;
31
 
    _colormap = 0;
32
 
    _visualPtr = 0;
33
 
 
34
 
    _dpyPtr = XOpenDisplay(_displayPtr);
35
 
    this->testDisplay();
36
 
    _screen = DefaultScreen(_dpyPtr);
37
 
    setupXRender();
38
 
}
39
 
 
40
 
void QtDisplay::testDisplay()
41
 
{
42
 
    if (!_dpyPtr) {
43
 
        exit(1);
44
 
    }
45
 
 
46
 
}
47
 
 
48
 
QtDisplay::~QtDisplay()
49
 
{
50
 
 
51
 
}
52
 
 
53
 
/*Manpage : function Proto types
54
 
 1.) XVisualInfo *XGetVisualInfo ( Display *display , long vinfo_mask , XVisualInfo *vinfo_template , int *nitems_return );
55
 
 
56
 
 2.)
57
 
 */
58
 
 
59
 
void QtDisplay::setupXRender()
60
 
{
61
 
    int tmp, tmp2;
62
 
    if (!XRenderQueryExtension(_dpyPtr, &tmp, &tmp2))
63
 
        return;
64
 
 
65
 
    XRenderPictFormat * m_xrender_pict_formatPtr;
66
 
 
67
 
    int m_xv_count = 0;
68
 
    XVisualInfo m_xvinfo;
69
 
    XVisualInfo * m_xvinfoAddr = &m_xvinfo;
70
 
 
71
 
    m_xvinfo.depth = 32;
72
 
    m_xvinfo.c_class = TrueColor;
73
 
    m_xvinfo.screen = _screen;
74
 
 
75
 
    long m_vinfo_mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
76
 
 
77
 
    XVisualInfo * m_xvinfoPtr;
78
 
    m_xvinfoPtr = XGetVisualInfo(_dpyPtr, m_vinfo_mask, m_xvinfoAddr, &m_xv_count);
79
 
 
80
 
    for (int index = 0; index < m_xv_count ; index++) {
81
 
        m_xrender_pict_formatPtr = XRenderFindVisualFormat(_dpyPtr,
82
 
            m_xvinfoPtr[index].visual);
83
 
 
84
 
        if (m_xrender_pict_formatPtr->type == PictTypeDirect) {
85
 
            if (m_xrender_pict_formatPtr->direct.alphaMask) {
86
 
                _visualPtr = m_xvinfoPtr[index].visual;
87
 
                _colormap = XCreateColormap(_dpyPtr, RootWindow(_dpyPtr,_screen), _visualPtr, AllocNone);
88
 
            }
89
 
        }
90
 
    }
91
 
 
92
 
}
93
 
 
94
 
#endif // LANCELOT_HAVE_COMPOSITING