~timo-jyrinki/ubuntu/trusty/maliit-framework/fix_qt52

« back to all changes in this revision

Viewing changes to src/mimxextension.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* * This file is part of Maliit framework *
2
 
 *
3
 
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
 
 * All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * This library is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Lesser General Public
10
 
 * License version 2.1 as published by the Free Software Foundation
11
 
 * and appearing in the file LICENSE.LGPL included in the packaging
12
 
 * of this file.
13
 
 */
14
 
 
15
 
#include <QDebug>
16
 
#include <QX11Info>
17
 
 
18
 
#include "mimxextension.h"
19
 
 
20
 
#include <X11/extensions/Xcomposite.h>
21
 
#include <X11/extensions/Xdamage.h>
22
 
 
23
 
MImXExtension::MImXExtension(const char *name)
24
 
    : available(false),
25
 
      major_code(0),
26
 
      event_base(0),
27
 
      error_base(0)
28
 
{
29
 
    available = XQueryExtension(QX11Info::display(), name, &major_code, &event_base, &error_base);
30
 
}
31
 
 
32
 
bool MImXExtension::supported(int required_major, int required_minor) const
33
 
{
34
 
    if (!available)
35
 
        return false;
36
 
 
37
 
    int major = required_major, minor = required_minor;
38
 
    if (!queryVersion(&major, &minor))
39
 
        return false;
40
 
 
41
 
    if (required_major == 0 && required_minor == 0)
42
 
        return true;
43
 
 
44
 
    if (major < required_major || (major == required_major && minor < required_minor))
45
 
        return false;
46
 
 
47
 
    return true;
48
 
}
49
 
 
50
 
MImXCompositeExtension::MImXCompositeExtension()
51
 
    : MImXExtension(COMPOSITE_NAME)
52
 
{
53
 
}
54
 
 
55
 
bool MImXCompositeExtension::queryVersion(int *major, int *minor) const
56
 
{
57
 
    return XCompositeQueryVersion(QX11Info::display(), major, minor) != 0;
58
 
}
59
 
 
60
 
MImXDamageExtension::MImXDamageExtension()
61
 
    : MImXExtension(DAMAGE_NAME)
62
 
{
63
 
}
64
 
 
65
 
bool MImXDamageExtension::queryVersion(int *major, int *minor) const
66
 
{
67
 
    return XDamageQueryVersion(QX11Info::display(), major, minor) != 0;
68
 
}