Remove Windows and X11 from src/widgets/platforms.
This is dead code, unused with QPA in place, so remove it to avoid confusion caused through grepping for class names existing in both old and new places. Mac code is left in place for now, as some of it is still in use. Change-Id: Ia82cd5bbabe71285ca997f79d8fd9c0504e32c28 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
1cae2fdb86
commit
a2337f79ff
@ -22,13 +22,7 @@ contains(QT_CONFIG, egl): {
|
||||
!isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL
|
||||
}
|
||||
|
||||
wince*: SOURCES += egl/qegl_wince.cpp
|
||||
|
||||
symbian {
|
||||
SOURCES += egl/qegl_symbian.cpp
|
||||
} else {
|
||||
SOURCES += egl/qegl_qpa.cpp
|
||||
}
|
||||
SOURCES += egl/qegl_qpa.cpp
|
||||
} else:symbian: {
|
||||
DEFINES += QT_NO_EGL
|
||||
SOURCES += egl/qegl_stub.cpp
|
||||
|
@ -1,88 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui/qpaintdevice.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
#include <QtGui/private/qapplication_p.h>
|
||||
|
||||
#include "qegl_p.h"
|
||||
#include "qeglcontext_p.h"
|
||||
|
||||
#include <coecntrl.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
EGLNativeDisplayType QEgl::nativeDisplay()
|
||||
{
|
||||
return EGL_DEFAULT_DISPLAY;
|
||||
}
|
||||
|
||||
EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
|
||||
{
|
||||
return (EGLNativeWindowType)(widget->winId()->DrawableWindow());
|
||||
}
|
||||
|
||||
EGLNativePixmapType QEgl::nativePixmap(QPixmap*)
|
||||
{
|
||||
qWarning("QEgl: EGL pixmap surfaces not implemented yet on Symbian");
|
||||
return (EGLNativePixmapType)0;
|
||||
}
|
||||
|
||||
// Set pixel format and other properties based on a paint device.
|
||||
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
|
||||
{
|
||||
if(!dev)
|
||||
return;
|
||||
|
||||
int devType = dev->devType();
|
||||
if (devType == QInternal::Image) {
|
||||
setPixelFormat(static_cast<QImage *>(dev)->format());
|
||||
} else {
|
||||
QImage::Format format = QImage::Format_RGB32;
|
||||
if (QApplicationPrivate::instance() && QApplicationPrivate::instance()->useTranslucentEGLSurfaces)
|
||||
format = QImage::Format_ARGB32_Premultiplied;
|
||||
setPixelFormat(format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui/qpaintdevice.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
|
||||
#include "qegl_p.h"
|
||||
#include "qeglcontext_p.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
EGLNativeDisplayType QEgl::nativeDisplay()
|
||||
{
|
||||
HDC myDc = GetDC(0);
|
||||
if (!myDc) {
|
||||
qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
|
||||
return EGL_DEFAULT_DISPLAY;
|
||||
}
|
||||
return EGLNativeDisplayType(myDc);
|
||||
}
|
||||
|
||||
EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
|
||||
{
|
||||
return (EGLNativeWindowType)(widget->winId());
|
||||
}
|
||||
|
||||
EGLNativePixmapType QEgl::nativePixmap(QPixmap*)
|
||||
{
|
||||
qWarning("QEgl: EGL pixmap surfaces not supported on WinCE");
|
||||
return (EGLNativePixmapType)0;
|
||||
}
|
||||
|
||||
// Set pixel format and other properties based on a paint device.
|
||||
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
|
||||
{
|
||||
int devType = dev->devType();
|
||||
if (devType == QInternal::Image)
|
||||
setPixelFormat(static_cast<QImage *>(dev)->format());
|
||||
else
|
||||
setPixelFormat(QImage::Format_RGB16); // XXX
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,471 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include <QtGui/private/qt_x11_p.h>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
#include <QtGui/qplatformpixmap_qpa.h>
|
||||
#include <QtGui/private/qpixmap_x11_p.h>
|
||||
#include <QtGui/private/qimagepixmapcleanuphooks_p.h>
|
||||
|
||||
#include <QtGui/qpaintdevice.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
#include <QtGui/qcolormap.h>
|
||||
|
||||
#include "QtGui/private/qegl_p.h"
|
||||
#include "QtGui/private/qeglcontext_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
EGLNativeDisplayType QEgl::nativeDisplay()
|
||||
{
|
||||
Display *xdpy = QX11Info::display();
|
||||
if (!xdpy) {
|
||||
qWarning("QEglContext::getDisplay(): X11 display is not open");
|
||||
return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
return EGLNativeDisplayType(xdpy);
|
||||
}
|
||||
|
||||
EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
|
||||
{
|
||||
return (EGLNativeWindowType)(widget->winId());
|
||||
}
|
||||
|
||||
EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap)
|
||||
{
|
||||
return (EGLNativePixmapType)(pixmap->handle());
|
||||
}
|
||||
|
||||
static int countBits(unsigned long mask)
|
||||
{
|
||||
int count = 0;
|
||||
while (mask != 0) {
|
||||
if (mask & 1)
|
||||
++count;
|
||||
mask >>= 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// Set the pixel format parameters from the visual in "xinfo".
|
||||
void QEglProperties::setVisualFormat(const QX11Info *xinfo)
|
||||
{
|
||||
if (!xinfo)
|
||||
return;
|
||||
Visual *visual = (Visual*)xinfo->visual();
|
||||
if (!visual)
|
||||
return;
|
||||
if (visual->c_class != TrueColor && visual->c_class != DirectColor)
|
||||
return;
|
||||
setValue(EGL_RED_SIZE, countBits(visual->red_mask));
|
||||
setValue(EGL_GREEN_SIZE, countBits(visual->green_mask));
|
||||
setValue(EGL_BLUE_SIZE, countBits(visual->blue_mask));
|
||||
|
||||
EGLint alphaBits = 0;
|
||||
#if !defined(QT_NO_XRENDER)
|
||||
XRenderPictFormat *format;
|
||||
format = XRenderFindVisualFormat(xinfo->display(), visual);
|
||||
if (format && (format->type == PictTypeDirect) && format->direct.alphaMask) {
|
||||
alphaBits = countBits(format->direct.alphaMask);
|
||||
qDebug("QEglProperties::setVisualFormat() - visual's alphaMask is %d", alphaBits);
|
||||
}
|
||||
#endif
|
||||
setValue(EGL_ALPHA_SIZE, alphaBits);
|
||||
}
|
||||
|
||||
extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
|
||||
|
||||
// Set pixel format and other properties based on a paint device.
|
||||
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
if (dev->devType() == QInternal::Image)
|
||||
setPixelFormat(static_cast<QImage *>(dev)->format());
|
||||
else
|
||||
setVisualFormat(qt_x11Info(dev));
|
||||
}
|
||||
|
||||
//#define QT_DEBUG_X11_VISUAL_SELECTION 1
|
||||
|
||||
VisualID QEgl::getCompatibleVisualId(EGLConfig config)
|
||||
{
|
||||
VisualID visualId = 0;
|
||||
EGLint eglValue = 0;
|
||||
|
||||
EGLint configRedSize = 0;
|
||||
eglGetConfigAttrib(display(), config, EGL_RED_SIZE, &configRedSize);
|
||||
|
||||
EGLint configGreenSize = 0;
|
||||
eglGetConfigAttrib(display(), config, EGL_GREEN_SIZE, &configGreenSize);
|
||||
|
||||
EGLint configBlueSize = 0;
|
||||
eglGetConfigAttrib(display(), config, EGL_BLUE_SIZE, &configBlueSize);
|
||||
|
||||
EGLint configAlphaSize = 0;
|
||||
eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &configAlphaSize);
|
||||
|
||||
eglGetConfigAttrib(display(), config, EGL_CONFIG_ID, &eglValue);
|
||||
int configId = eglValue;
|
||||
|
||||
// See if EGL provided a valid VisualID:
|
||||
eglGetConfigAttrib(display(), config, EGL_NATIVE_VISUAL_ID, &eglValue);
|
||||
visualId = (VisualID)eglValue;
|
||||
if (visualId) {
|
||||
// EGL has suggested a visual id, so get the rest of the visual info for that id:
|
||||
XVisualInfo visualInfoTemplate;
|
||||
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
|
||||
visualInfoTemplate.visualid = visualId;
|
||||
|
||||
XVisualInfo *chosenVisualInfo;
|
||||
int matchingCount = 0;
|
||||
chosenVisualInfo = XGetVisualInfo(X11->display, VisualIDMask, &visualInfoTemplate, &matchingCount);
|
||||
if (chosenVisualInfo) {
|
||||
// Skip size checks if implementation supports non-matching visual
|
||||
// and config (http://bugreports.qt.nokia.com/browse/QTBUG-9444).
|
||||
if (QEgl::hasExtension("EGL_NV_post_convert_rounding")) {
|
||||
XFree(chosenVisualInfo);
|
||||
return visualId;
|
||||
}
|
||||
|
||||
int visualRedSize = countBits(chosenVisualInfo->red_mask);
|
||||
int visualGreenSize = countBits(chosenVisualInfo->green_mask);
|
||||
int visualBlueSize = countBits(chosenVisualInfo->blue_mask);
|
||||
int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size
|
||||
|
||||
#if !defined(QT_NO_XRENDER)
|
||||
if (X11->use_xrender) {
|
||||
// If we have XRender, actually check the visual supplied by EGL is ARGB
|
||||
XRenderPictFormat *format;
|
||||
format = XRenderFindVisualFormat(X11->display, chosenVisualInfo->visual);
|
||||
if (format && (format->type == PictTypeDirect))
|
||||
visualAlphaSize = countBits(format->direct.alphaMask);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool visualMatchesConfig = false;
|
||||
if ( visualRedSize == configRedSize &&
|
||||
visualGreenSize == configGreenSize &&
|
||||
visualBlueSize == configBlueSize )
|
||||
{
|
||||
// We need XRender to check the alpha channel size of the visual. If we don't have
|
||||
// the alpha size, we don't check it against the EGL config's alpha size.
|
||||
if (visualAlphaSize >= 0)
|
||||
visualMatchesConfig = visualAlphaSize == configAlphaSize;
|
||||
else
|
||||
visualMatchesConfig = true;
|
||||
}
|
||||
|
||||
if (!visualMatchesConfig) {
|
||||
if (visualAlphaSize >= 0) {
|
||||
qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable",
|
||||
(int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize,
|
||||
configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize);
|
||||
} else {
|
||||
qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable",
|
||||
(int)visualId, visualRedSize, visualGreenSize, visualBlueSize,
|
||||
configId, configRedSize, configGreenSize, configBlueSize);
|
||||
}
|
||||
visualId = 0;
|
||||
}
|
||||
} else {
|
||||
qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
|
||||
(int)visualId, configId);
|
||||
visualId = 0;
|
||||
}
|
||||
XFree(chosenVisualInfo);
|
||||
}
|
||||
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
|
||||
else
|
||||
qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
|
||||
#endif
|
||||
|
||||
if (visualId) {
|
||||
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
|
||||
if (configAlphaSize > 0)
|
||||
qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
|
||||
else
|
||||
qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
|
||||
#endif
|
||||
return visualId;
|
||||
}
|
||||
|
||||
|
||||
// If EGL didn't give us a valid visual ID, try XRender
|
||||
#if !defined(QT_NO_XRENDER)
|
||||
if (!visualId && X11->use_xrender) {
|
||||
XVisualInfo visualInfoTemplate;
|
||||
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
|
||||
|
||||
visualInfoTemplate.c_class = TrueColor;
|
||||
|
||||
XVisualInfo *matchingVisuals;
|
||||
int matchingCount = 0;
|
||||
matchingVisuals = XGetVisualInfo(X11->display,
|
||||
VisualClassMask,
|
||||
&visualInfoTemplate,
|
||||
&matchingCount);
|
||||
|
||||
for (int i = 0; i < matchingCount; ++i) {
|
||||
XRenderPictFormat *format;
|
||||
format = XRenderFindVisualFormat(X11->display, matchingVisuals[i].visual);
|
||||
|
||||
// Check the format for the visual matches the EGL config
|
||||
if ( (countBits(format->direct.redMask) == configRedSize) &&
|
||||
(countBits(format->direct.greenMask) == configGreenSize) &&
|
||||
(countBits(format->direct.blueMask) == configBlueSize) &&
|
||||
(countBits(format->direct.alphaMask) == configAlphaSize) )
|
||||
{
|
||||
visualId = matchingVisuals[i].visualid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchingVisuals)
|
||||
XFree(matchingVisuals);
|
||||
|
||||
}
|
||||
if (visualId) {
|
||||
# ifdef QT_DEBUG_X11_VISUAL_SELECTION
|
||||
if (configAlphaSize > 0)
|
||||
qDebug("Using ARGB Visual ID %d provided by XRender for EGL config %d", (int)visualId, configId);
|
||||
else
|
||||
qDebug("Using Opaque Visual ID %d provided by XRender for EGL config %d", (int)visualId, configId);
|
||||
# endif // QT_DEBUG_X11_VISUAL_SELECTION
|
||||
return visualId;
|
||||
}
|
||||
# ifdef QT_DEBUG_X11_VISUAL_SELECTION
|
||||
else
|
||||
qDebug("Failed to find an XVisual which matches EGL config %d using XRender", configId);
|
||||
# endif // QT_DEBUG_X11_VISUAL_SELECTION
|
||||
|
||||
#endif //!defined(QT_NO_XRENDER)
|
||||
|
||||
|
||||
// Finally, if XRender also failed to find a visual (or isn't present), try to
|
||||
// use XGetVisualInfo and only use the bit depths to match on:
|
||||
if (!visualId) {
|
||||
XVisualInfo visualInfoTemplate;
|
||||
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
|
||||
XVisualInfo *matchingVisuals;
|
||||
int matchingCount = 0;
|
||||
|
||||
visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;
|
||||
matchingVisuals = XGetVisualInfo(X11->display,
|
||||
VisualDepthMask,
|
||||
&visualInfoTemplate,
|
||||
&matchingCount);
|
||||
if (!matchingVisuals) {
|
||||
// Try again without taking the alpha channel into account:
|
||||
visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;
|
||||
matchingVisuals = XGetVisualInfo(X11->display,
|
||||
VisualDepthMask,
|
||||
&visualInfoTemplate,
|
||||
&matchingCount);
|
||||
}
|
||||
|
||||
if (matchingVisuals) {
|
||||
visualId = matchingVisuals[0].visualid;
|
||||
XFree(matchingVisuals);
|
||||
}
|
||||
}
|
||||
|
||||
if (visualId) {
|
||||
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
|
||||
qDebug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
|
||||
#endif
|
||||
return visualId;
|
||||
}
|
||||
|
||||
qWarning("Unable to find an X11 visual which matches EGL config %d", configId);
|
||||
return (VisualID)0;
|
||||
}
|
||||
|
||||
void qt_set_winid_on_widget(QWidget* w, Qt::HANDLE id)
|
||||
{
|
||||
w->create(id);
|
||||
}
|
||||
|
||||
|
||||
// NOTE: The X11 version of createSurface will re-create the native drawable if it's visual doesn't
|
||||
// match the one for the passed in EGLConfig
|
||||
EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEglProperties *properties)
|
||||
{
|
||||
int devType = device->devType();
|
||||
|
||||
if (devType == QInternal::Pbuffer) {
|
||||
// TODO
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
QX11PlatformPixmap *x11PlatformPixmap = 0;
|
||||
if (devType == QInternal::Pixmap) {
|
||||
QPlatformPixmap *pmd = static_cast<QPixmap*>(device)->data_ptr().data();
|
||||
if (pmd->classId() == QPlatformPixmap::X11Class)
|
||||
x11PlatformPixmap = static_cast<QX11PlatformPixmap*>(pmd);
|
||||
else {
|
||||
// TODO: Replace the pixmap's data with a new QX11PlatformPixmap
|
||||
qWarning("WARNING: Creating an EGL surface on a QPixmap is only supported for QX11PlatformPixmap");
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
} else if ((devType != QInternal::Widget) && (devType != QInternal::Pbuffer)) {
|
||||
qWarning("WARNING: Creating an EGLSurface for device type %d isn't supported", devType);
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
VisualID visualId = QEgl::getCompatibleVisualId(config);
|
||||
EGLint alphaSize;
|
||||
eglGetConfigAttrib(QEgl::display(), config, EGL_ALPHA_SIZE, &alphaSize);
|
||||
|
||||
if (devType == QInternal::Widget) {
|
||||
QWidget *widget = static_cast<QWidget*>(device);
|
||||
|
||||
VisualID currentVisualId = 0;
|
||||
if (widget->testAttribute(Qt::WA_WState_Created))
|
||||
currentVisualId = XVisualIDFromVisual((Visual*)widget->x11Info().visual());
|
||||
|
||||
if (currentVisualId != visualId) {
|
||||
// The window is either not created or has the wrong visual. Either way, we need
|
||||
// to create a window with the correct visual and call create() on the widget:
|
||||
|
||||
bool visible = widget->isVisible();
|
||||
if (visible)
|
||||
widget->hide();
|
||||
|
||||
XVisualInfo visualInfo;
|
||||
visualInfo.visualid = visualId;
|
||||
{
|
||||
XVisualInfo *visualInfoPtr;
|
||||
int matchingCount = 0;
|
||||
visualInfoPtr = XGetVisualInfo(widget->x11Info().display(), VisualIDMask,
|
||||
&visualInfo, &matchingCount);
|
||||
Q_ASSERT(visualInfoPtr); // visualId really should be valid!
|
||||
visualInfo = *visualInfoPtr;
|
||||
XFree(visualInfoPtr);
|
||||
}
|
||||
|
||||
Window parentWindow = RootWindow(widget->x11Info().display(), widget->x11Info().screen());
|
||||
if (widget->parentWidget())
|
||||
parentWindow = widget->parentWidget()->winId();
|
||||
|
||||
XSetWindowAttributes windowAttribs;
|
||||
QColormap colmap = QColormap::instance(widget->x11Info().screen());
|
||||
windowAttribs.background_pixel = colmap.pixel(widget->palette().color(widget->backgroundRole()));
|
||||
windowAttribs.border_pixel = colmap.pixel(Qt::black);
|
||||
|
||||
unsigned int valueMask = CWBackPixel|CWBorderPixel;
|
||||
if (alphaSize > 0) {
|
||||
windowAttribs.colormap = XCreateColormap(widget->x11Info().display(), parentWindow,
|
||||
visualInfo.visual, AllocNone);
|
||||
valueMask |= CWColormap;
|
||||
}
|
||||
|
||||
Window window = XCreateWindow(widget->x11Info().display(), parentWindow,
|
||||
widget->x(), widget->y(), widget->width(), widget->height(),
|
||||
0, visualInfo.depth, InputOutput, visualInfo.visual,
|
||||
valueMask, &windowAttribs);
|
||||
|
||||
// This is a nasty hack to get round the fact that we can't be a friend of QWidget:
|
||||
qt_set_winid_on_widget(widget, window);
|
||||
|
||||
if (visible)
|
||||
widget->show();
|
||||
}
|
||||
|
||||
// At this point, the widget's window should be created and have the correct visual. Now we
|
||||
// just need to create the EGL surface for it:
|
||||
const int *props;
|
||||
if (properties)
|
||||
props = properties->properties();
|
||||
else
|
||||
props = 0;
|
||||
EGLSurface surf = eglCreateWindowSurface(QEgl::display(), config, (EGLNativeWindowType)widget->winId(), props);
|
||||
if (surf == EGL_NO_SURFACE)
|
||||
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
|
||||
return surf;
|
||||
}
|
||||
|
||||
if (x11PlatformPixmap) {
|
||||
// X11 Pixmaps are only created with a depth, so that's all we need to check
|
||||
EGLint configDepth;
|
||||
eglGetConfigAttrib(QEgl::display(), config, EGL_BUFFER_SIZE , &configDepth);
|
||||
if (x11PlatformPixmap->depth() != configDepth) {
|
||||
// The bit depths are wrong which means the EGLConfig isn't compatable with
|
||||
// this pixmap. So we need to replace the pixmap's existing data with a new
|
||||
// one which is created with the correct depth:
|
||||
|
||||
#ifndef QT_NO_XRENDER
|
||||
if (configDepth == 32) {
|
||||
qWarning("Warning: EGLConfig's depth (32) != pixmap's depth (%d), converting to ARGB32",
|
||||
x11PlatformPixmap->depth());
|
||||
x11PlatformPixmap->convertToARGB32(true);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
qWarning("Warning: EGLConfig's depth (%d) != pixmap's depth (%d)",
|
||||
configDepth, x11PlatformPixmap->depth());
|
||||
}
|
||||
}
|
||||
|
||||
QEglProperties surfaceAttribs;
|
||||
|
||||
// If the pixmap can't be bound to a texture, it's pretty useless
|
||||
surfaceAttribs.setValue(EGL_TEXTURE_TARGET, EGL_TEXTURE_2D);
|
||||
if (alphaSize > 0)
|
||||
surfaceAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA);
|
||||
else
|
||||
surfaceAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB);
|
||||
|
||||
EGLSurface surf = eglCreatePixmapSurface(QEgl::display(), config,
|
||||
(EGLNativePixmapType) x11PlatformPixmap->handle(),
|
||||
surfaceAttribs.properties());
|
||||
x11PlatformPixmap->gl_surface = (void*)surf;
|
||||
QImagePixmapCleanupHooks::enableCleanupHooks(x11PlatformPixmap);
|
||||
return surf;
|
||||
}
|
||||
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -60,7 +60,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QX11Info;
|
||||
class QPaintDevice;
|
||||
|
||||
class Q_GUI_EXPORT QEglProperties
|
||||
|
@ -60,7 +60,6 @@ class QImageWriter;
|
||||
class QImageReader;
|
||||
class QColor;
|
||||
class QVariant;
|
||||
class QX11Info;
|
||||
class QPlatformPixmap;
|
||||
|
||||
class Q_GUI_EXPORT QPixmap : public QPaintDevice
|
||||
|
@ -831,9 +831,6 @@ QT_CLASS_LIB(QWidgetList, QtWidgets, qwindowdefs.h)
|
||||
QT_CLASS_LIB(QWidgetMapper, QtWidgets, qwindowdefs.h)
|
||||
QT_CLASS_LIB(QWidgetSet, QtWidgets, qwindowdefs.h)
|
||||
QT_CLASS_LIB(QWindowSystemInterface, QtWidgets, qwindowsysteminterface_qpa.h)
|
||||
QT_CLASS_LIB(QX11EmbedWidget, QtWidgets, qx11embed_x11.h)
|
||||
QT_CLASS_LIB(QX11EmbedContainer, QtWidgets, qx11embed_x11.h)
|
||||
QT_CLASS_LIB(QX11Info, QtWidgets, qx11info_x11.h)
|
||||
QT_CLASS_LIB(QGenericMatrix, QtGui, qgenericmatrix.h)
|
||||
QT_CLASS_LIB(QMatrix2x2, QtGui, qgenericmatrix.h)
|
||||
QT_CLASS_LIB(QMatrix2x3, QtGui, qgenericmatrix.h)
|
||||
|
@ -93,7 +93,7 @@
|
||||
In the illustration above, Application One's primary screen is
|
||||
screen 0, and App Two's primary screen is screen 1.
|
||||
|
||||
\sa QApplication, QApplication::desktop(), QX11Info::appRootWindow()
|
||||
\sa QApplication, QApplication::desktop()
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -1,224 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qguieventdispatcher_glib_p.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qx11info_x11.h"
|
||||
|
||||
#include "qt_x11_p.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct GX11EventSource
|
||||
{
|
||||
GSource source;
|
||||
GPollFD pollfd;
|
||||
QEventLoop::ProcessEventsFlags flags;
|
||||
QGuiEventDispatcherGlib *q;
|
||||
QGuiEventDispatcherGlibPrivate *d;
|
||||
};
|
||||
|
||||
class QGuiEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QGuiEventDispatcherGlib)
|
||||
|
||||
public:
|
||||
QGuiEventDispatcherGlibPrivate();
|
||||
GX11EventSource *x11EventSource;
|
||||
QList<XEvent> queuedUserInputEvents;
|
||||
};
|
||||
|
||||
static gboolean x11EventSourcePrepare(GSource *s, gint *timeout)
|
||||
{
|
||||
if (timeout)
|
||||
*timeout = -1;
|
||||
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
|
||||
return (XEventsQueued(X11->display, QueuedAfterFlush)
|
||||
|| (!(source->flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& !source->d->queuedUserInputEvents.isEmpty()));
|
||||
}
|
||||
|
||||
static gboolean x11EventSourceCheck(GSource *s)
|
||||
{
|
||||
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
|
||||
return (XEventsQueued(X11->display, QueuedAfterFlush)
|
||||
|| (!(source->flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& !source->d->queuedUserInputEvents.isEmpty()));
|
||||
}
|
||||
|
||||
static gboolean x11EventSourceDispatch(GSource *s, GSourceFunc callback, gpointer user_data)
|
||||
{
|
||||
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
|
||||
|
||||
ulong marker = XNextRequest(X11->display);
|
||||
do {
|
||||
XEvent event;
|
||||
if (!(source->flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& !source->d->queuedUserInputEvents.isEmpty()) {
|
||||
// process a pending user input event
|
||||
event = source->d->queuedUserInputEvents.takeFirst();
|
||||
} else if (XEventsQueued(X11->display, QueuedAlready)) {
|
||||
// process events from the X server
|
||||
XNextEvent(X11->display, &event);
|
||||
|
||||
if (source->flags & QEventLoop::ExcludeUserInputEvents) {
|
||||
// queue user input events
|
||||
switch (event.type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
case XKeyPress:
|
||||
case XKeyRelease:
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
source->d->queuedUserInputEvents.append(event);
|
||||
continue;
|
||||
|
||||
case ClientMessage:
|
||||
// only keep the wm_take_focus and
|
||||
// _qt_scrolldone protocols, queue all other
|
||||
// client messages
|
||||
if (event.xclient.format == 32) {
|
||||
if (event.xclient.message_type == ATOM(WM_PROTOCOLS) &&
|
||||
(Atom) event.xclient.data.l[0] == ATOM(WM_TAKE_FOCUS)) {
|
||||
break;
|
||||
} else if (event.xclient.message_type == ATOM(_QT_SCROLL_DONE)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
source->d->queuedUserInputEvents.append(event);
|
||||
continue;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no event to process
|
||||
break;
|
||||
}
|
||||
|
||||
// send through event filter
|
||||
if (source->q->filterEvent(&event))
|
||||
continue;
|
||||
|
||||
if (qApp->x11ProcessEvent(&event) == 1)
|
||||
return true;
|
||||
|
||||
if (event.xany.serial >= marker)
|
||||
goto out;
|
||||
} while (XEventsQueued(X11->display, QueuedAfterFlush));
|
||||
|
||||
out:
|
||||
|
||||
source->d->runTimersOnceWithNormalPriority();
|
||||
|
||||
if (callback)
|
||||
callback(user_data);
|
||||
return true;
|
||||
}
|
||||
|
||||
static GSourceFuncs x11EventSourceFuncs = {
|
||||
x11EventSourcePrepare,
|
||||
x11EventSourceCheck,
|
||||
x11EventSourceDispatch,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate()
|
||||
{
|
||||
x11EventSource = reinterpret_cast<GX11EventSource *>(g_source_new(&x11EventSourceFuncs,
|
||||
sizeof(GX11EventSource)));
|
||||
g_source_set_can_recurse(&x11EventSource->source, true);
|
||||
|
||||
memset(&x11EventSource->pollfd, 0, sizeof(GPollFD));
|
||||
x11EventSource->flags = QEventLoop::AllEvents;
|
||||
x11EventSource->q = 0;
|
||||
x11EventSource->d = 0;
|
||||
|
||||
g_source_attach(&x11EventSource->source, mainContext);
|
||||
}
|
||||
|
||||
QGuiEventDispatcherGlib::QGuiEventDispatcherGlib(QObject *parent)
|
||||
: QEventDispatcherGlib(*new QGuiEventDispatcherGlibPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QGuiEventDispatcherGlib::~QGuiEventDispatcherGlib()
|
||||
{
|
||||
Q_D(QGuiEventDispatcherGlib);
|
||||
|
||||
g_source_remove_poll(&d->x11EventSource->source, &d->x11EventSource->pollfd);
|
||||
g_source_destroy(&d->x11EventSource->source);
|
||||
d->x11EventSource = 0;
|
||||
}
|
||||
|
||||
bool QGuiEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
{
|
||||
Q_D(QGuiEventDispatcherGlib);
|
||||
QEventLoop::ProcessEventsFlags saved_flags = d->x11EventSource->flags;
|
||||
d->x11EventSource->flags = flags;
|
||||
bool returnValue = QEventDispatcherGlib::processEvents(flags);
|
||||
d->x11EventSource->flags = saved_flags;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void QGuiEventDispatcherGlib::startingUp()
|
||||
{
|
||||
Q_D(QGuiEventDispatcherGlib);
|
||||
d->x11EventSource->pollfd.fd = XConnectionNumber(X11->display);
|
||||
d->x11EventSource->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
|
||||
d->x11EventSource->q = this;
|
||||
d->x11EventSource->d = d;
|
||||
g_source_add_poll(&d->x11EventSource->source, &d->x11EventSource->pollfd);
|
||||
}
|
||||
|
||||
void QGuiEventDispatcherGlib::flush()
|
||||
{
|
||||
XFlush(X11->display);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGUIEVENTDISPATCHER_GLIB_P_H
|
||||
#define QGUIEVENTDISPATCHER_GLIB_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of the QLibrary class. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/private/qeventdispatcher_glib_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGuiEventDispatcherGlibPrivate;
|
||||
|
||||
class QGuiEventDispatcherGlib : public QEventDispatcherGlib
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QGuiEventDispatcherGlib)
|
||||
|
||||
public:
|
||||
explicit QGuiEventDispatcherGlib(QObject *parent = 0);
|
||||
~QGuiEventDispatcherGlib();
|
||||
|
||||
bool processEvents(QEventLoop::ProcessEventsFlags flags);
|
||||
|
||||
void startingUp();
|
||||
void flush();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QGUIEVENTDISPATCHER_GLIB_P_H
|
@ -65,10 +65,6 @@
|
||||
#define SPI_GETDROPSHADOW 0x1024
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_WS_X11)
|
||||
#include "qx11info_x11.h"
|
||||
#include <qwidget.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -11953,13 +11953,6 @@ void QWidget::clearMask()
|
||||
setMask(QRegion());
|
||||
}
|
||||
|
||||
/*! \fn const QX11Info &QWidget::x11Info() const
|
||||
Returns information about the configuration of the X display used to display
|
||||
the widget.
|
||||
|
||||
\warning This function is only available on X11.
|
||||
*/
|
||||
|
||||
/*! \fn Qt::HANDLE QWidget::x11PictureHandle() const
|
||||
Returns the X11 Picture handle of the widget for XRender
|
||||
support. Use of this function is not portable. This function will
|
||||
|
@ -101,9 +101,6 @@ class QGraphicsEffect;
|
||||
class QRasterWindowSurface;
|
||||
class QUnifiedToolbarSurface;
|
||||
class QPixmap;
|
||||
#if defined(Q_WS_X11)
|
||||
class QX11Info;
|
||||
#endif
|
||||
|
||||
class QWidgetData
|
||||
{
|
||||
|
@ -677,7 +677,6 @@ public:
|
||||
|
||||
// *************************** Platform specific ************************************
|
||||
#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
|
||||
QX11Info xinfo;
|
||||
Qt::HANDLE picture;
|
||||
static QWidget *mouseGrabber;
|
||||
static QWidget *keyboardGrabber;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,398 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qclipboard.h"
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qapplication_p.h"
|
||||
#include "qeventloop.h"
|
||||
#include "qwidget.h"
|
||||
#include "qevent.h"
|
||||
#include "qmime.h"
|
||||
#include "qt_windows.h"
|
||||
#include "qdnd_p.h"
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qsystemlibrary_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include "qguifunctions_wince.h"
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
HRESULT QtCeGetClipboard(IDataObject** obj);
|
||||
HRESULT QtCeSetClipboard(IDataObject* obj);
|
||||
void QtCeFlushClipboard();
|
||||
|
||||
#define OleGetClipboard QtCeGetClipboard
|
||||
#define OleSetClipboard QtCeSetClipboard
|
||||
#define OleFlushClipboard QtCeFlushClipboard
|
||||
|
||||
#endif
|
||||
|
||||
typedef BOOL (WINAPI *PtrIsHungAppWindow)(HWND);
|
||||
|
||||
static PtrIsHungAppWindow ptrIsHungAppWindow = 0;
|
||||
|
||||
class QClipboardWatcher : public QInternalMimeData {
|
||||
public:
|
||||
QClipboardWatcher()
|
||||
: QInternalMimeData()
|
||||
{
|
||||
}
|
||||
|
||||
bool hasFormat_sys(const QString &mimetype) const;
|
||||
QStringList formats_sys() const;
|
||||
QVariant retrieveData_sys(const QString &mimetype, QVariant::Type preferredType) const;
|
||||
};
|
||||
|
||||
|
||||
bool QClipboardWatcher::hasFormat_sys(const QString &mime) const
|
||||
{
|
||||
IDataObject * pDataObj = 0;
|
||||
|
||||
if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
|
||||
return false;
|
||||
|
||||
bool has = QWindowsMime::converterToMime(mime, pDataObj) != 0;
|
||||
|
||||
pDataObj->Release();
|
||||
|
||||
return has;
|
||||
}
|
||||
|
||||
QStringList QClipboardWatcher::formats_sys() const
|
||||
{
|
||||
QStringList fmts;
|
||||
IDataObject * pDataObj = 0;
|
||||
|
||||
if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
|
||||
return QStringList();
|
||||
|
||||
fmts = QWindowsMime::allMimesForFormats(pDataObj);
|
||||
|
||||
pDataObj->Release();
|
||||
|
||||
return fmts;
|
||||
}
|
||||
|
||||
QVariant QClipboardWatcher::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
|
||||
{
|
||||
QVariant result;
|
||||
IDataObject * pDataObj = 0;
|
||||
|
||||
if (OleGetClipboard(&pDataObj) != S_OK && !pDataObj) // Sanity
|
||||
return result;
|
||||
|
||||
QWindowsMime *converter = QWindowsMime::converterToMime(mimeType, pDataObj);
|
||||
|
||||
if (converter)
|
||||
result = converter->convertToMime(mimeType, pDataObj, type);
|
||||
|
||||
pDataObj->Release();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
class QClipboardData
|
||||
{
|
||||
public:
|
||||
QClipboardData()
|
||||
: iData(0)
|
||||
, nextClipboardViewer(0)
|
||||
{
|
||||
clipBoardViewer = new QWidget();
|
||||
clipBoardViewer->createWinId();
|
||||
clipBoardViewer->setObjectName(QLatin1String("internal clipboard owner"));
|
||||
// We don't need this internal widget to appear in QApplication::topLevelWidgets()
|
||||
if (QWidgetPrivate::allWidgets)
|
||||
QWidgetPrivate::allWidgets->remove(clipBoardViewer);
|
||||
}
|
||||
|
||||
~QClipboardData()
|
||||
{
|
||||
Q_ASSERT(clipBoardViewer->testAttribute(Qt::WA_WState_Created));
|
||||
ChangeClipboardChain(clipBoardViewer->internalWinId(), nextClipboardViewer);
|
||||
delete clipBoardViewer;
|
||||
releaseIData();
|
||||
}
|
||||
|
||||
void releaseIData()
|
||||
{
|
||||
if (iData) {
|
||||
delete iData->mimeData();
|
||||
iData->releaseQt();
|
||||
iData->Release();
|
||||
iData = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QOleDataObject * iData;
|
||||
QWidget *clipBoardViewer;
|
||||
HWND nextClipboardViewer;
|
||||
QClipboardWatcher watcher;
|
||||
};
|
||||
|
||||
static QClipboardData *ptrClipboardData = 0;
|
||||
|
||||
static QClipboardData *clipboardData()
|
||||
{
|
||||
if (ptrClipboardData == 0) {
|
||||
ptrClipboardData = new QClipboardData;
|
||||
// this needs to be done here to avoid recursion
|
||||
Q_ASSERT(ptrClipboardData->clipBoardViewer->testAttribute(Qt::WA_WState_Created));
|
||||
ptrClipboardData->nextClipboardViewer = SetClipboardViewer(ptrClipboardData->clipBoardViewer->internalWinId());
|
||||
}
|
||||
return ptrClipboardData;
|
||||
}
|
||||
|
||||
static void cleanupClipboardData()
|
||||
{
|
||||
delete ptrClipboardData;
|
||||
ptrClipboardData = 0;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
HRESULT QtCeGetClipboard(IDataObject** obj)
|
||||
{
|
||||
HWND owner = ptrClipboardData->clipBoardViewer->internalWinId();
|
||||
if (!OpenClipboard(owner))
|
||||
return !S_OK;
|
||||
|
||||
if (!IsClipboardFormatAvailable(CF_TEXT) && !IsClipboardFormatAvailable(CF_UNICODETEXT))
|
||||
return !S_OK;
|
||||
|
||||
HANDLE clipData = GetClipboardData(CF_TEXT);
|
||||
QString clipText;
|
||||
if (clipData == 0) {
|
||||
clipData = GetClipboardData(CF_UNICODETEXT);
|
||||
if (clipData != 0)
|
||||
clipText = QString::fromWCharArray((wchar_t *)clipData);
|
||||
} else {
|
||||
clipText = QString::fromLatin1((const char*)clipData);
|
||||
}
|
||||
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
mimeData->setText(clipText);
|
||||
QOleDataObject* data = new QOleDataObject(mimeData);
|
||||
*obj = data;
|
||||
CloseClipboard();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT QtCeSetClipboard(IDataObject* obj)
|
||||
{
|
||||
HWND owner = ptrClipboardData->clipBoardViewer->internalWinId();
|
||||
if (!OpenClipboard(owner))
|
||||
return !S_OK;
|
||||
|
||||
bool result = false;
|
||||
if (obj == 0) {
|
||||
result = true;
|
||||
EmptyClipboard();
|
||||
CloseClipboard();
|
||||
} else {
|
||||
QOleDataObject* qobj = static_cast<QOleDataObject*>(obj);
|
||||
|
||||
const QMimeData* data = qobj->mimeData();
|
||||
if (data->hasText()) {
|
||||
EmptyClipboard();
|
||||
result = SetClipboardData(CF_UNICODETEXT, wcsdup(reinterpret_cast<const wchar_t *> (data->text().utf16()))) != NULL;
|
||||
CloseClipboard();
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result ? S_OK : !S_OK;
|
||||
}
|
||||
|
||||
void QtCeFlushClipboard() { }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
QClipboard::~QClipboard()
|
||||
{
|
||||
cleanupClipboardData();
|
||||
}
|
||||
|
||||
void QClipboard::setMimeData(QMimeData *src, Mode mode)
|
||||
{
|
||||
if (mode != Clipboard)
|
||||
return;
|
||||
QClipboardData *d = clipboardData();
|
||||
|
||||
if (!(d->iData && d->iData->mimeData() == src)) {
|
||||
d->releaseIData();
|
||||
d->iData = new QOleDataObject(src);
|
||||
}
|
||||
|
||||
if (OleSetClipboard(d->iData) != S_OK) {
|
||||
d->releaseIData();
|
||||
qErrnoWarning("QClipboard::setMimeData: Failed to set data on clipboard");
|
||||
return;
|
||||
}
|
||||
#if defined(Q_OS_WINCE)
|
||||
// As WinCE does not support notifications we send the signal here
|
||||
// We will get no event when the clipboard changes outside...
|
||||
emit dataChanged();
|
||||
emit changed(Clipboard);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QClipboard::clear(Mode mode)
|
||||
{
|
||||
if (mode != Clipboard) return;
|
||||
|
||||
QClipboardData *d = clipboardData();
|
||||
|
||||
d->releaseIData();
|
||||
|
||||
if (OleSetClipboard(0) != S_OK) {
|
||||
qErrnoWarning("QClipboard::clear: Failed to clear data on clipboard");
|
||||
return;
|
||||
}
|
||||
#if defined(Q_OS_WINCE)
|
||||
// As WinCE does not support notifications we send the signal here
|
||||
// We will get no event when the clipboard changes outside...
|
||||
emit dataChanged();
|
||||
emit changed(Clipboard);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QClipboard::event(QEvent *e)
|
||||
{
|
||||
if (e->type() != QEvent::Clipboard)
|
||||
return QObject::event(e);
|
||||
|
||||
QClipboardData *d = clipboardData();
|
||||
|
||||
MSG *m = (MSG *)((QClipboardEvent*)e)->data();
|
||||
if (!m) {
|
||||
// this is sent to render all formats at app shut down
|
||||
if (ownsClipboard()) {
|
||||
OleFlushClipboard();
|
||||
d->releaseIData();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool propagate = false;
|
||||
|
||||
if (m->message == WM_CHANGECBCHAIN) {
|
||||
if ((HWND)m->wParam == d->nextClipboardViewer)
|
||||
d->nextClipboardViewer = (HWND)m->lParam;
|
||||
else
|
||||
propagate = true;
|
||||
} else if (m->message == WM_DRAWCLIPBOARD) {
|
||||
emitChanged(QClipboard::Clipboard);
|
||||
if (!ownsClipboard() && d->iData)
|
||||
// clean up the clipboard object if we no longer own the clipboard
|
||||
d->releaseIData();
|
||||
propagate = true;
|
||||
}
|
||||
if (propagate && d->nextClipboardViewer) {
|
||||
if (ptrIsHungAppWindow == 0) {
|
||||
QSystemLibrary library(QLatin1String("User32"));
|
||||
ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow");
|
||||
}
|
||||
if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) {
|
||||
qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO);
|
||||
} else {
|
||||
SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QClipboard::connectNotify(const char *signal)
|
||||
{
|
||||
if (qstrcmp(signal,SIGNAL(dataChanged())) == 0) {
|
||||
// ensure we are up and running but block signals so the dataChange signal
|
||||
// is not emitted while being connected to.
|
||||
bool blocked = blockSignals(true);
|
||||
QClipboardData *d = clipboardData();
|
||||
blockSignals(blocked);
|
||||
Q_UNUSED(d);
|
||||
}
|
||||
}
|
||||
|
||||
const QMimeData *QClipboard::mimeData(Mode mode) const
|
||||
{
|
||||
if (mode != Clipboard)
|
||||
return 0;
|
||||
|
||||
QClipboardData *data = clipboardData();
|
||||
// sort cut for local copy / paste
|
||||
if (ownsClipboard() && data->iData->mimeData())
|
||||
return data->iData->mimeData();
|
||||
return &data->watcher;
|
||||
}
|
||||
|
||||
bool QClipboard::supportsMode(Mode mode) const
|
||||
{
|
||||
return (mode == Clipboard);
|
||||
}
|
||||
|
||||
bool QClipboard::ownsMode(Mode mode) const
|
||||
{
|
||||
if (mode == Clipboard) {
|
||||
QClipboardData *d = clipboardData();
|
||||
#if !defined(Q_OS_WINCE)
|
||||
return d->iData && OleIsCurrentClipboard(d->iData) == S_OK;
|
||||
#else
|
||||
return d->iData && GetClipboardOwner() == d->clipBoardViewer->internalWinId();
|
||||
#endif
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void QClipboard::ownerDestroyed()
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_CLIPBOARD
|
@ -1,201 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcolor.h"
|
||||
#include "qcolormap.h"
|
||||
#include "qvector.h"
|
||||
#include "qt_windows.h"
|
||||
|
||||
#if defined(Q_WS_WINCE)
|
||||
#include "qguifunctions_wince.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QColormapPrivate
|
||||
{
|
||||
public:
|
||||
inline QColormapPrivate()
|
||||
: ref(1), mode(QColormap::Direct), depth(0), hpal(0)
|
||||
{ }
|
||||
|
||||
QAtomicInt ref;
|
||||
|
||||
QColormap::Mode mode;
|
||||
int depth;
|
||||
int numcolors;
|
||||
|
||||
HPALETTE hpal;
|
||||
QVector<QColor> palette;
|
||||
};
|
||||
|
||||
static QColormapPrivate *screenMap = 0;
|
||||
|
||||
void QColormap::initialize()
|
||||
{
|
||||
HDC dc = qt_win_display_dc();
|
||||
|
||||
screenMap = new QColormapPrivate;
|
||||
screenMap->depth = GetDeviceCaps(dc, BITSPIXEL);
|
||||
|
||||
screenMap->numcolors = -1;
|
||||
if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE)
|
||||
screenMap->numcolors = GetDeviceCaps(dc, SIZEPALETTE);
|
||||
|
||||
if (screenMap->numcolors <= 16 || screenMap->numcolors > 256) // no need to create palette
|
||||
return;
|
||||
|
||||
LOGPALETTE* pal = 0;
|
||||
int numPalEntries = 6*6*6; // color cube
|
||||
|
||||
pal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + numPalEntries * sizeof(PALETTEENTRY));
|
||||
// Make 6x6x6 color cube
|
||||
int idx = 0;
|
||||
for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
|
||||
for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
|
||||
for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
|
||||
pal->palPalEntry[idx].peRed = ir;
|
||||
pal->palPalEntry[idx].peGreen = ig;
|
||||
pal->palPalEntry[idx].peBlue = ib;
|
||||
pal->palPalEntry[idx].peFlags = 0;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pal->palVersion = 0x300;
|
||||
pal->palNumEntries = numPalEntries;
|
||||
|
||||
screenMap->hpal = CreatePalette(pal);
|
||||
if (!screenMap->hpal)
|
||||
qErrnoWarning("QColor::initialize: Failed to create logical palette");
|
||||
free (pal);
|
||||
|
||||
SelectPalette(dc, screenMap->hpal, FALSE);
|
||||
RealizePalette(dc);
|
||||
|
||||
PALETTEENTRY paletteEntries[256];
|
||||
screenMap->numcolors = GetPaletteEntries(screenMap->hpal, 0, 255, paletteEntries);
|
||||
|
||||
screenMap->palette.resize(screenMap->numcolors);
|
||||
for (int i = 0; i < screenMap->numcolors; i++) {
|
||||
screenMap->palette[i] = qRgb(paletteEntries[i].peRed,
|
||||
paletteEntries[i].peGreen,
|
||||
paletteEntries[i].peBlue);
|
||||
}
|
||||
}
|
||||
|
||||
void QColormap::cleanup()
|
||||
{
|
||||
if (!screenMap)
|
||||
return;
|
||||
|
||||
if (screenMap->hpal) { // delete application global
|
||||
DeleteObject(screenMap->hpal); // palette
|
||||
screenMap->hpal = 0;
|
||||
}
|
||||
|
||||
delete screenMap;
|
||||
screenMap = 0;
|
||||
}
|
||||
|
||||
QColormap QColormap::instance(int)
|
||||
{
|
||||
Q_ASSERT_X(screenMap, "QColormap",
|
||||
"A QApplication object needs to be constructed before QColormap is used.");
|
||||
return QColormap();
|
||||
}
|
||||
|
||||
QColormap::QColormap()
|
||||
: d(screenMap)
|
||||
{ d->ref.ref(); }
|
||||
|
||||
QColormap::QColormap(const QColormap &colormap)
|
||||
:d (colormap.d)
|
||||
{ d->ref.ref(); }
|
||||
|
||||
QColormap::~QColormap()
|
||||
{
|
||||
if (!d->ref.deref())
|
||||
delete d;
|
||||
}
|
||||
|
||||
QColormap::Mode QColormap::mode() const
|
||||
{ return d->mode; }
|
||||
|
||||
int QColormap::depth() const
|
||||
{ return d->depth; }
|
||||
|
||||
int QColormap::size() const
|
||||
{ return d->numcolors; }
|
||||
|
||||
uint QColormap::pixel(const QColor &color) const
|
||||
{
|
||||
const QColor c = color.toRgb();
|
||||
COLORREF rgb = RGB(c.red(), c.green(), c.blue());
|
||||
if (d->hpal)
|
||||
return PALETTEINDEX(GetNearestPaletteIndex(d->hpal, rgb));
|
||||
return rgb;
|
||||
}
|
||||
|
||||
const QColor QColormap::colorAt(uint pixel) const
|
||||
{
|
||||
if (d->hpal) {
|
||||
if (pixel < uint(d->numcolors))
|
||||
return d->palette.at(pixel);
|
||||
return QColor();
|
||||
}
|
||||
return QColor(GetRValue(pixel), GetGValue(pixel), GetBValue(pixel));
|
||||
}
|
||||
|
||||
|
||||
HPALETTE QColormap::hPal()
|
||||
{ return screenMap ? screenMap->hpal : 0; }
|
||||
|
||||
|
||||
const QVector<QColor> QColormap::colormap() const
|
||||
{ return d->palette; }
|
||||
|
||||
QColormap &QColormap::operator=(const QColormap &colormap)
|
||||
{ qAtomicAssign(d, colormap.d); return *this; }
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,493 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qcursor_p.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qcursor.h>
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
||||
#include <qimage.h>
|
||||
#include <qt_windows.h>
|
||||
#include <private/qapplication_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*****************************************************************************
|
||||
Internal QCursorData class
|
||||
*****************************************************************************/
|
||||
|
||||
QCursorData::QCursorData(Qt::CursorShape s)
|
||||
: cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0)
|
||||
{
|
||||
ref = 1;
|
||||
}
|
||||
|
||||
QCursorData::~QCursorData()
|
||||
{
|
||||
delete bm;
|
||||
delete bmm;
|
||||
#if !defined(Q_WS_WINCE) || defined(GWES_ICONCURS)
|
||||
if (hcurs)
|
||||
DestroyCursor(hcurs);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
|
||||
qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
|
||||
QCursorData *c = qt_cursorTable[0];
|
||||
c->ref.ref();
|
||||
return c;
|
||||
}
|
||||
QCursorData *d = new QCursorData;
|
||||
d->bm = new QBitmap(bitmap);
|
||||
d->bmm = new QBitmap(mask);
|
||||
d->hcurs = 0;
|
||||
d->cshape = Qt::BitmapCursor;
|
||||
d->hx = hotX >= 0 ? hotX : bitmap.width()/2;
|
||||
d->hy = hotY >= 0 ? hotY : bitmap.height()/2;
|
||||
return d;
|
||||
}
|
||||
|
||||
HCURSOR QCursor::handle() const
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (!d->hcurs)
|
||||
d->update();
|
||||
return d->hcurs;
|
||||
}
|
||||
|
||||
QCursor::QCursor(HCURSOR handle)
|
||||
{
|
||||
d = new QCursorData(Qt::CustomCursor);
|
||||
d->hcurs = handle;
|
||||
}
|
||||
|
||||
#endif //QT_NO_CURSOR
|
||||
|
||||
QPoint QCursor::pos()
|
||||
{
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
return QPoint(p.x, p.y);
|
||||
}
|
||||
|
||||
void QCursor::setPos(int x, int y)
|
||||
{
|
||||
SetCursorPos(x, y);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
||||
extern HBITMAP qt_createIconMask(const QBitmap &bitmap);
|
||||
|
||||
static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy)
|
||||
{
|
||||
HCURSOR cur = 0;
|
||||
#if !defined(Q_WS_WINCE)
|
||||
QBitmap mask = pixmap.mask();
|
||||
if (mask.isNull()) {
|
||||
mask = QBitmap(pixmap.size());
|
||||
mask.fill(Qt::color1);
|
||||
}
|
||||
|
||||
HBITMAP ic = pixmap.toWinHBITMAP(QPixmap::Alpha);
|
||||
HBITMAP im = qt_createIconMask(mask);
|
||||
|
||||
ICONINFO ii;
|
||||
ii.fIcon = 0;
|
||||
ii.xHotspot = hx;
|
||||
ii.yHotspot = hy;
|
||||
ii.hbmMask = im;
|
||||
ii.hbmColor = ic;
|
||||
|
||||
cur = CreateIconIndirect(&ii);
|
||||
|
||||
DeleteObject(ic);
|
||||
DeleteObject(im);
|
||||
#elif defined(GWES_ICONCURS)
|
||||
QImage bbits, mbits;
|
||||
bool invb, invm;
|
||||
bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
|
||||
mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono);
|
||||
invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
|
||||
invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
|
||||
|
||||
int sysW = GetSystemMetrics(SM_CXCURSOR);
|
||||
int sysH = GetSystemMetrics(SM_CYCURSOR);
|
||||
int sysN = qMax(1, sysW / 8);
|
||||
int n = qMax(1, bbits.width() / 8);
|
||||
int h = bbits.height();
|
||||
|
||||
uchar* xBits = new uchar[sysH * sysN];
|
||||
uchar* xMask = new uchar[sysH * sysN];
|
||||
int x = 0;
|
||||
for (int i = 0; i < sysH; ++i) {
|
||||
if (i >= h) {
|
||||
memset(&xBits[x] , 255, sysN);
|
||||
memset(&xMask[x] , 0, sysN);
|
||||
x += sysN;
|
||||
} else {
|
||||
int fillWidth = n > sysN ? sysN : n;
|
||||
uchar *bits = bbits.scanLine(i);
|
||||
uchar *mask = mbits.scanLine(i);
|
||||
for (int j = 0; j < fillWidth; ++j) {
|
||||
uchar b = bits[j];
|
||||
uchar m = mask[j];
|
||||
if (invb)
|
||||
b ^= 0xFF;
|
||||
if (invm)
|
||||
m ^= 0xFF;
|
||||
xBits[x] = ~m;
|
||||
xMask[x] = b ^ m;
|
||||
++x;
|
||||
}
|
||||
for (int j = fillWidth; j < sysN; ++j ) {
|
||||
xBits[x] = 255;
|
||||
xMask[x] = 0;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
|
||||
xBits, xMask);
|
||||
#else
|
||||
Q_UNUSED(pixmap);
|
||||
Q_UNUSED(hx);
|
||||
Q_UNUSED(hy);
|
||||
#endif
|
||||
return cur;
|
||||
}
|
||||
|
||||
void QCursorData::update()
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (hcurs)
|
||||
return;
|
||||
|
||||
if (cshape == Qt::BitmapCursor && !pixmap.isNull()) {
|
||||
hcurs = create32BitCursor(pixmap, hx, hy);
|
||||
if (hcurs)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Non-standard Windows cursors are created from bitmaps
|
||||
|
||||
static const uchar vsplit_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar vsplitm_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
||||
0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
||||
0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
||||
0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar hsplit_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
|
||||
0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar hsplitm_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
|
||||
0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
|
||||
0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
|
||||
0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar phand_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
|
||||
0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
|
||||
0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00,
|
||||
0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00,
|
||||
0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00,
|
||||
0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00,
|
||||
0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00,
|
||||
0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
static const uchar phandm_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
|
||||
0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
|
||||
0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00,
|
||||
0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00,
|
||||
0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00,
|
||||
0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00,
|
||||
0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00,
|
||||
0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
static const uchar openhand_bits[] = {
|
||||
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
|
||||
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
|
||||
0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
|
||||
static const uchar openhandm_bits[] = {
|
||||
0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
|
||||
0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
|
||||
0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
|
||||
static const uchar closedhand_bits[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
|
||||
0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
|
||||
0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
|
||||
static const uchar closedhandm_bits[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
|
||||
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
|
||||
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
|
||||
|
||||
static const uchar * const cursor_bits32[] = {
|
||||
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
|
||||
phand_bits, phandm_bits
|
||||
};
|
||||
|
||||
wchar_t *sh = 0;
|
||||
switch (cshape) { // map to windows cursor
|
||||
case Qt::ArrowCursor:
|
||||
sh = IDC_ARROW;
|
||||
break;
|
||||
case Qt::UpArrowCursor:
|
||||
sh = IDC_UPARROW;
|
||||
break;
|
||||
case Qt::CrossCursor:
|
||||
sh = IDC_CROSS;
|
||||
break;
|
||||
case Qt::WaitCursor:
|
||||
sh = IDC_WAIT;
|
||||
break;
|
||||
case Qt::IBeamCursor:
|
||||
sh = IDC_IBEAM;
|
||||
break;
|
||||
case Qt::SizeVerCursor:
|
||||
sh = IDC_SIZENS;
|
||||
break;
|
||||
case Qt::SizeHorCursor:
|
||||
sh = IDC_SIZEWE;
|
||||
break;
|
||||
case Qt::SizeBDiagCursor:
|
||||
sh = IDC_SIZENESW;
|
||||
break;
|
||||
case Qt::SizeFDiagCursor:
|
||||
sh = IDC_SIZENWSE;
|
||||
break;
|
||||
case Qt::SizeAllCursor:
|
||||
sh = IDC_SIZEALL;
|
||||
break;
|
||||
case Qt::ForbiddenCursor:
|
||||
sh = IDC_NO;
|
||||
break;
|
||||
case Qt::WhatsThisCursor:
|
||||
sh = IDC_HELP;
|
||||
break;
|
||||
case Qt::BusyCursor:
|
||||
sh = IDC_APPSTARTING;
|
||||
break;
|
||||
case Qt::PointingHandCursor:
|
||||
sh = IDC_HAND;
|
||||
break;
|
||||
case Qt::BlankCursor:
|
||||
case Qt::SplitVCursor:
|
||||
case Qt::SplitHCursor:
|
||||
case Qt::OpenHandCursor:
|
||||
case Qt::ClosedHandCursor:
|
||||
case Qt::BitmapCursor: {
|
||||
QImage bbits, mbits;
|
||||
bool invb, invm;
|
||||
if (cshape == Qt::BlankCursor) {
|
||||
bbits = QImage(32, 32, QImage::Format_Mono);
|
||||
bbits.fill(0); // ignore color table
|
||||
mbits = bbits.copy();
|
||||
hx = hy = 16;
|
||||
invb = invm = false;
|
||||
} else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
|
||||
bool open = cshape == Qt::OpenHandCursor;
|
||||
QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
|
||||
QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
|
||||
bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
|
||||
mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
|
||||
hx = hy = 8;
|
||||
invb = invm = false;
|
||||
} else if (cshape != Qt::BitmapCursor) {
|
||||
int i = cshape - Qt::SplitVCursor;
|
||||
QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]);
|
||||
QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]);
|
||||
bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
|
||||
mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
|
||||
if (cshape == Qt::PointingHandCursor) {
|
||||
hx = 7;
|
||||
hy = 0;
|
||||
} else
|
||||
hx = hy = 16;
|
||||
invb = invm = false;
|
||||
} else {
|
||||
bbits = bm->toImage().convertToFormat(QImage::Format_Mono);
|
||||
mbits = bmm->toImage().convertToFormat(QImage::Format_Mono);
|
||||
invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
|
||||
invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
|
||||
}
|
||||
int n = qMax(1, bbits.width() / 8);
|
||||
int h = bbits.height();
|
||||
#if !defined(Q_WS_WINCE)
|
||||
uchar* xBits = new uchar[h * n];
|
||||
uchar* xMask = new uchar[h * n];
|
||||
int x = 0;
|
||||
for (int i = 0; i < h; ++i) {
|
||||
uchar *bits = bbits.scanLine(i);
|
||||
uchar *mask = mbits.scanLine(i);
|
||||
for (int j = 0; j < n; ++j) {
|
||||
uchar b = bits[j];
|
||||
uchar m = mask[j];
|
||||
if (invb)
|
||||
b ^= 0xff;
|
||||
if (invm)
|
||||
m ^= 0xff;
|
||||
xBits[x] = ~m;
|
||||
xMask[x] = b ^ m;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
hcurs = CreateCursor(qWinAppInst(), hx, hy, bbits.width(), bbits.height(),
|
||||
xBits, xMask);
|
||||
delete [] xBits;
|
||||
delete [] xMask;
|
||||
#elif defined(GWES_ICONCURS) // Q_WS_WINCE
|
||||
// Windows CE only supports fixed cursor size.
|
||||
int sysW = GetSystemMetrics(SM_CXCURSOR);
|
||||
int sysH = GetSystemMetrics(SM_CYCURSOR);
|
||||
int sysN = qMax(1, sysW / 8);
|
||||
uchar* xBits = new uchar[sysH * sysN];
|
||||
uchar* xMask = new uchar[sysH * sysN];
|
||||
int x = 0;
|
||||
for (int i = 0; i < sysH; ++i) {
|
||||
if (i >= h) {
|
||||
memset(&xBits[x] , 255, sysN);
|
||||
memset(&xMask[x] , 0, sysN);
|
||||
x += sysN;
|
||||
} else {
|
||||
int fillWidth = n > sysN ? sysN : n;
|
||||
uchar *bits = bbits.scanLine(i);
|
||||
uchar *mask = mbits.scanLine(i);
|
||||
for (int j = 0; j < fillWidth; ++j) {
|
||||
uchar b = bits[j];
|
||||
uchar m = mask[j];
|
||||
if (invb)
|
||||
b ^= 0xFF;
|
||||
if (invm)
|
||||
m ^= 0xFF;
|
||||
xBits[x] = ~m;
|
||||
xMask[x] = b ^ m;
|
||||
++x;
|
||||
}
|
||||
for (int j = fillWidth; j < sysN; ++j ) {
|
||||
xBits[x] = 255;
|
||||
xMask[x] = 0;
|
||||
++x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hcurs = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
|
||||
xBits, xMask);
|
||||
delete [] xBits;
|
||||
delete [] xMask;
|
||||
#else
|
||||
Q_UNUSED(n);
|
||||
Q_UNUSED(h);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
case Qt::DragCopyCursor:
|
||||
case Qt::DragMoveCursor:
|
||||
case Qt::DragLinkCursor: {
|
||||
QPixmap pixmap = QApplicationPrivate::instance()->getPixmapCursor(cshape);
|
||||
hcurs = create32BitCursor(pixmap, hx, hy);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning("QCursor::update: Invalid cursor shape %d", cshape);
|
||||
return;
|
||||
}
|
||||
#ifdef Q_WS_WINCE
|
||||
hcurs = LoadCursor(0, sh);
|
||||
#else
|
||||
hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QT_NO_CURSOR
|
@ -1,387 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdesktopwidget.h"
|
||||
#include "qt_windows.h"
|
||||
#include "qapplication_p.h"
|
||||
#include <private/qsystemlibrary_p.h>
|
||||
#include <qvector.h>
|
||||
#include <limits.h>
|
||||
#ifdef Q_WS_WINCE
|
||||
#include <sipapi.h>
|
||||
#endif
|
||||
#include "qwidget_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesktopWidgetPrivate : public QWidgetPrivate
|
||||
{
|
||||
public:
|
||||
QDesktopWidgetPrivate();
|
||||
~QDesktopWidgetPrivate();
|
||||
|
||||
static void init(QDesktopWidget *that);
|
||||
static void cleanup();
|
||||
static int screenCount;
|
||||
static int primaryScreen;
|
||||
|
||||
static QVector<QRect> *rects;
|
||||
static QVector<QRect> *workrects;
|
||||
|
||||
struct MONITORINFO
|
||||
{
|
||||
DWORD cbSize;
|
||||
RECT rcMonitor;
|
||||
RECT rcWork;
|
||||
DWORD dwFlags;
|
||||
};
|
||||
|
||||
typedef BOOL (WINAPI *InfoFunc)(HMONITOR, MONITORINFO*);
|
||||
typedef BOOL (QT_WIN_CALLBACK *EnumProc)(HMONITOR, HDC, LPRECT, LPARAM);
|
||||
typedef BOOL (WINAPI *EnumFunc)(HDC, LPCRECT, EnumProc, LPARAM);
|
||||
|
||||
static EnumFunc enumDisplayMonitors;
|
||||
static InfoFunc getMonitorInfo;
|
||||
static int refcount;
|
||||
};
|
||||
|
||||
int QDesktopWidgetPrivate::screenCount = 1;
|
||||
int QDesktopWidgetPrivate::primaryScreen = 0;
|
||||
QDesktopWidgetPrivate::EnumFunc QDesktopWidgetPrivate::enumDisplayMonitors = 0;
|
||||
QDesktopWidgetPrivate::InfoFunc QDesktopWidgetPrivate::getMonitorInfo = 0;
|
||||
QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
|
||||
QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
|
||||
static int screen_number = 0;
|
||||
int QDesktopWidgetPrivate::refcount = 0;
|
||||
#ifdef Q_WS_WINCE_WM
|
||||
// Use SIP information, if available
|
||||
// SipGetInfo is not supported by SSDK (no definition!).
|
||||
static inline void qt_get_sip_info(QRect &rect)
|
||||
{
|
||||
SIPINFO sip;
|
||||
memset(&sip, 0, sizeof(SIPINFO));
|
||||
sip.cbSize = sizeof(SIPINFO);
|
||||
if (SipGetInfo(&sip))
|
||||
rect = QRect(QPoint(sip.rcVisibleDesktop.left, sip.rcVisibleDesktop.top),
|
||||
QPoint(sip.rcVisibleDesktop.right - 1, sip.rcVisibleDesktop.bottom - 1));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
BOOL QT_WIN_CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM)
|
||||
{
|
||||
QDesktopWidgetPrivate::screenCount++;
|
||||
QDesktopWidgetPrivate::rects->resize(QDesktopWidgetPrivate::screenCount);
|
||||
QDesktopWidgetPrivate::workrects->resize(QDesktopWidgetPrivate::screenCount);
|
||||
// Get the MONITORINFO block
|
||||
QDesktopWidgetPrivate::MONITORINFO info;
|
||||
memset(&info, 0, sizeof(QDesktopWidgetPrivate::MONITORINFO));
|
||||
info.cbSize = sizeof(QDesktopWidgetPrivate::MONITORINFO);
|
||||
BOOL res = QDesktopWidgetPrivate::getMonitorInfo(hMonitor, &info);
|
||||
if (!res) {
|
||||
(*QDesktopWidgetPrivate::rects)[screen_number] = QRect();
|
||||
(*QDesktopWidgetPrivate::workrects)[screen_number] = QRect();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fill list of rects
|
||||
RECT r = info.rcMonitor;
|
||||
QRect qr(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
|
||||
(*QDesktopWidgetPrivate::rects)[screen_number] = qr;
|
||||
|
||||
r = info.rcWork;
|
||||
qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
|
||||
(*QDesktopWidgetPrivate::workrects)[screen_number] = qr;
|
||||
|
||||
if (info.dwFlags & 0x00000001) //MONITORINFOF_PRIMARY
|
||||
QDesktopWidgetPrivate::primaryScreen = screen_number;
|
||||
|
||||
++screen_number;
|
||||
// Stop the enumeration if we have them all
|
||||
return true;
|
||||
}
|
||||
|
||||
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
|
||||
{
|
||||
++refcount;
|
||||
}
|
||||
|
||||
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
|
||||
{
|
||||
if (rects)
|
||||
return;
|
||||
|
||||
rects = new QVector<QRect>();
|
||||
workrects = new QVector<QRect>();
|
||||
screenCount = 0;
|
||||
|
||||
#ifndef Q_OS_WINCE
|
||||
QSystemLibrary user32Lib(QLatin1String("user32"));
|
||||
enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
|
||||
getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
|
||||
|
||||
if (!enumDisplayMonitors || !getMonitorInfo) {
|
||||
screenCount = GetSystemMetrics(80); // SM_CMONITORS
|
||||
rects->resize(screenCount);
|
||||
for (int i = 0; i < screenCount; ++i)
|
||||
rects->replace(i, that->rect());
|
||||
return;
|
||||
}
|
||||
// Calls enumCallback
|
||||
enumDisplayMonitors(0, 0, enumCallback, 0);
|
||||
enumDisplayMonitors = 0;
|
||||
getMonitorInfo = 0;
|
||||
#else
|
||||
QSystemLibrary coreLib(QLatin1String("coredll"));
|
||||
// CE >= 4.0 case
|
||||
enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors");
|
||||
getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo");
|
||||
|
||||
if ((!enumDisplayMonitors || !getMonitorInfo)) {
|
||||
screenCount = GetSystemMetrics(SM_CMONITORS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!coreLib.isLoaded() || !enumDisplayMonitors || !getMonitorInfo) {
|
||||
rects->resize(screenCount);
|
||||
for (int i = 0; i < screenCount; ++i)
|
||||
(*rects)[i] = that->rect();
|
||||
|
||||
RECT r;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
|
||||
QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
|
||||
|
||||
#if defined(Q_WS_WINCE_WM)
|
||||
qt_get_sip_info(qr);
|
||||
#endif
|
||||
|
||||
workrects->resize(screenCount);
|
||||
for (int j = 0; j < screenCount; ++j)
|
||||
(*workrects)[j] = qr;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calls enumCallback
|
||||
enumDisplayMonitors(0, 0, enumCallback, 0);
|
||||
enumDisplayMonitors = 0;
|
||||
getMonitorInfo = 0;
|
||||
#endif // Q_WS_WINCE
|
||||
}
|
||||
|
||||
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
|
||||
{
|
||||
if (!--refcount)
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void QDesktopWidgetPrivate::cleanup()
|
||||
{
|
||||
screen_number = 0;
|
||||
screenCount = 1;
|
||||
primaryScreen = 0;
|
||||
enumDisplayMonitors = 0;
|
||||
getMonitorInfo = 0;
|
||||
delete rects;
|
||||
rects = 0;
|
||||
delete workrects;
|
||||
workrects = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
\omit
|
||||
Function is commented out in header
|
||||
\fn void *QDesktopWidget::handle(int screen) const
|
||||
|
||||
Returns the window system handle of the display device with the
|
||||
index \a screen, for low-level access. Using this function is not
|
||||
portable.
|
||||
|
||||
The return type varies with platform; see qwindowdefs.h for details.
|
||||
|
||||
\sa x11Display(), QPaintDevice::handle()
|
||||
\endomit
|
||||
*/
|
||||
|
||||
QDesktopWidget::QDesktopWidget()
|
||||
: QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
|
||||
{
|
||||
setObjectName(QLatin1String("desktop"));
|
||||
QDesktopWidgetPrivate::init(this);
|
||||
}
|
||||
|
||||
QDesktopWidget::~QDesktopWidget()
|
||||
{
|
||||
}
|
||||
|
||||
bool QDesktopWidget::isVirtualDesktop() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int QDesktopWidget::primaryScreen() const
|
||||
{
|
||||
return d_func()->primaryScreen;
|
||||
}
|
||||
|
||||
int QDesktopWidget::numScreens() const
|
||||
{
|
||||
return d_func()->screenCount;
|
||||
}
|
||||
|
||||
QWidget *QDesktopWidget::screen(int /* screen */)
|
||||
{
|
||||
// It seems that a Qt::WType_Desktop cannot be moved?
|
||||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
// MSVC 7.10 warns that d (the result of the expanded Q_D macro) as a local variable that is not referenced.
|
||||
// Therefore, we ignore that warning with the following pragmas
|
||||
// I've also tried to eliminate the macro, but to no use...
|
||||
// We pop it further down
|
||||
#ifdef Q_CC_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4189)
|
||||
#endif
|
||||
const QRect QDesktopWidget::availableGeometry(int screen) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
#ifdef Q_WS_WINCE_WM
|
||||
for(int i=0; i < d->workrects->size(); ++i)
|
||||
qt_get_sip_info((*d->workrects)[i]);
|
||||
#endif
|
||||
if (screen < 0 || screen >= d->screenCount)
|
||||
screen = d->primaryScreen;
|
||||
|
||||
return d->workrects->at(screen);
|
||||
}
|
||||
|
||||
const QRect QDesktopWidget::screenGeometry(int screen) const
|
||||
{
|
||||
const QDesktopWidgetPrivate *d = d_func();
|
||||
if (screen < 0 || screen >= d->screenCount)
|
||||
screen = d->primaryScreen;
|
||||
|
||||
return d->rects->at(screen);
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QWidget *widget) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
if (!widget)
|
||||
return d->primaryScreen;
|
||||
|
||||
QRect frame = widget->frameGeometry();
|
||||
if (!widget->isWindow())
|
||||
frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0)));
|
||||
|
||||
int maxSize = -1;
|
||||
int maxScreen = -1;
|
||||
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
QRect sect = d->rects->at(i).intersected(frame);
|
||||
int size = sect.width() * sect.height();
|
||||
if (size > maxSize && sect.width() > 0 && sect.height() > 0) {
|
||||
maxSize = size;
|
||||
maxScreen = i;
|
||||
}
|
||||
}
|
||||
|
||||
return maxScreen;
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QPoint &point) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
|
||||
int closestScreen = -1;
|
||||
int shortestDistance = INT_MAX;
|
||||
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
int thisDistance = d->pointToRect(point, d->rects->at(i));
|
||||
if (thisDistance < shortestDistance) {
|
||||
shortestDistance = thisDistance;
|
||||
closestScreen = i;
|
||||
}
|
||||
}
|
||||
|
||||
return closestScreen;
|
||||
}
|
||||
|
||||
void QDesktopWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
Q_D(QDesktopWidget);
|
||||
const QVector<QRect> oldrects(*d->rects);
|
||||
const QVector<QRect> oldworkrects(*d->workrects);
|
||||
int oldscreencount = d->screenCount;
|
||||
|
||||
QDesktopWidgetPrivate::cleanup();
|
||||
QDesktopWidgetPrivate::init(this);
|
||||
#ifdef Q_WS_WINCE_WM
|
||||
for(int i=0; i < d->workrects->size(); ++i)
|
||||
qt_get_sip_info((*d->workrects)[i]);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
|
||||
const QRect oldrect = oldrects[i];
|
||||
const QRect newrect = d->rects->at(i);
|
||||
if (oldrect != newrect)
|
||||
emit resized(i);
|
||||
}
|
||||
|
||||
for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
|
||||
const QRect oldrect = oldworkrects[j];
|
||||
const QRect newrect = d->workrects->at(j);
|
||||
if (oldrect != newrect)
|
||||
emit workAreaResized(j);
|
||||
}
|
||||
|
||||
if (oldscreencount != d->screenCount) {
|
||||
emit screenCountChanged(d->screenCount);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_CC_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,166 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qfont.h"
|
||||
#include "qfont_p.h"
|
||||
#include "qfontengine_p.h"
|
||||
#include "qtextengine_p.h"
|
||||
#include "qfontmetrics.h"
|
||||
#include "qfontinfo.h"
|
||||
|
||||
#include "qwidget.h"
|
||||
#include "qpainter.h"
|
||||
#include <limits.h>
|
||||
#include "qt_windows.h"
|
||||
#include <private/qapplication_p.h>
|
||||
#include "qapplication.h"
|
||||
#include <private/qunicodetables_p.h>
|
||||
#include <qfontdatabase.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern HDC shared_dc(); // common dc for all fonts
|
||||
extern QFont::Weight weightFromInteger(int weight); // qfontdatabase.cpp
|
||||
|
||||
// ### maybe move to qapplication_win
|
||||
QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/)
|
||||
{
|
||||
QString family = QString::fromWCharArray(lf.lfFaceName);
|
||||
QFont qf(family);
|
||||
qf.setItalic(lf.lfItalic);
|
||||
if (lf.lfWeight != FW_DONTCARE)
|
||||
qf.setWeight(weightFromInteger(lf.lfWeight));
|
||||
int lfh = qAbs(lf.lfHeight);
|
||||
qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY));
|
||||
qf.setUnderline(false);
|
||||
qf.setOverline(false);
|
||||
qf.setStrikeOut(false);
|
||||
return qf;
|
||||
}
|
||||
|
||||
|
||||
static inline float pixelSize(const QFontDef &request, int dpi)
|
||||
{
|
||||
float pSize;
|
||||
if (request.pointSize != -1)
|
||||
pSize = request.pointSize * dpi/ 72.;
|
||||
else
|
||||
pSize = request.pixelSize;
|
||||
return pSize;
|
||||
}
|
||||
|
||||
static inline float pointSize(const QFontDef &fd, int dpi)
|
||||
{
|
||||
float pSize;
|
||||
if (fd.pointSize < 0)
|
||||
pSize = fd.pixelSize * 72. / ((float)dpi);
|
||||
else
|
||||
pSize = fd.pointSize;
|
||||
return pSize;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
QFont member functions
|
||||
*****************************************************************************/
|
||||
|
||||
void QFont::initialize()
|
||||
{
|
||||
}
|
||||
|
||||
void QFont::cleanup()
|
||||
{
|
||||
QFontCache::cleanup();
|
||||
}
|
||||
|
||||
HFONT QFont::handle() const
|
||||
{
|
||||
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
|
||||
Q_ASSERT(engine != 0);
|
||||
if (engine->type() == QFontEngine::Multi)
|
||||
engine = static_cast<QFontEngineMulti *>(engine)->engine(0);
|
||||
if (engine->type() == QFontEngine::Win)
|
||||
return static_cast<QFontEngineWin *>(engine)->hfont;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString QFont::rawName() const
|
||||
{
|
||||
return family();
|
||||
}
|
||||
|
||||
void QFont::setRawName(const QString &name)
|
||||
{
|
||||
setFamily(name);
|
||||
}
|
||||
|
||||
QString QFont::defaultFamily() const
|
||||
{
|
||||
switch(d->request.styleHint) {
|
||||
case QFont::Times:
|
||||
return QString::fromLatin1("Times New Roman");
|
||||
case QFont::Courier:
|
||||
case QFont::Monospace:
|
||||
return QString::fromLatin1("Courier New");
|
||||
case QFont::Decorative:
|
||||
return QString::fromLatin1("Bookman Old Style");
|
||||
case QFont::Cursive:
|
||||
return QString::fromLatin1("Comic Sans MS");
|
||||
case QFont::Fantasy:
|
||||
return QString::fromLatin1("Impact");
|
||||
case QFont::Helvetica:
|
||||
return QString::fromLatin1("Arial");
|
||||
case QFont::System:
|
||||
default:
|
||||
return QString::fromLatin1("MS Sans Serif");
|
||||
}
|
||||
}
|
||||
|
||||
QString QFont::lastResortFamily() const
|
||||
{
|
||||
return QString::fromLatin1("helvetica");
|
||||
}
|
||||
|
||||
QString QFont::lastResortFont() const
|
||||
{
|
||||
return QString::fromLatin1("arial");
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,164 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QFONTENGINE_WIN_P_H
|
||||
#define QFONTENGINE_WIN_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qconfig.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNativeImage;
|
||||
|
||||
class QFontEngineWin : public QFontEngine
|
||||
{
|
||||
public:
|
||||
QFontEngineWin(const QString &name, HFONT, bool, LOGFONT);
|
||||
~QFontEngineWin();
|
||||
|
||||
virtual QFixed lineThickness() const;
|
||||
virtual Properties properties() const;
|
||||
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
|
||||
virtual FaceId faceId() const;
|
||||
virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
|
||||
virtual int synthesized() const;
|
||||
virtual QFixed emSquareSize() const;
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const;
|
||||
|
||||
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
|
||||
QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
|
||||
HGDIOBJ selectDesignFont() const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t g) { return boundingBox(g, QTransform()); }
|
||||
virtual glyph_metrics_t boundingBox(glyph_t g, const QTransform &t);
|
||||
|
||||
|
||||
virtual QFixed ascent() const;
|
||||
virtual QFixed descent() const;
|
||||
virtual QFixed leading() const;
|
||||
virtual QFixed xHeight() const;
|
||||
virtual QFixed averageCharWidth() const;
|
||||
virtual qreal maxCharWidth() const;
|
||||
virtual qreal minLeftBearing() const;
|
||||
virtual qreal minRightBearing() const;
|
||||
|
||||
virtual const char *name() const;
|
||||
|
||||
bool canRender(const QChar *string, int len);
|
||||
|
||||
Type type() const;
|
||||
|
||||
virtual QImage alphaMapForGlyph(glyph_t t) { return alphaMapForGlyph(t, QTransform()); }
|
||||
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
|
||||
virtual QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
|
||||
|
||||
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
|
||||
|
||||
#ifndef Q_CC_MINGW
|
||||
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
|
||||
#endif
|
||||
|
||||
int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const;
|
||||
void getCMap();
|
||||
|
||||
#ifndef Q_WS_WINCE
|
||||
bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const;
|
||||
#endif
|
||||
|
||||
QString _name;
|
||||
QString uniqueFamilyName;
|
||||
HFONT hfont;
|
||||
LOGFONT logfont;
|
||||
uint stockFont : 1;
|
||||
uint ttf : 1;
|
||||
uint hasOutline : 1;
|
||||
TEXTMETRIC tm;
|
||||
int lw;
|
||||
const unsigned char *cmap;
|
||||
QByteArray cmapTable;
|
||||
mutable qreal lbearing;
|
||||
mutable qreal rbearing;
|
||||
QFixed designToDevice;
|
||||
int unitsPerEm;
|
||||
QFixed x_height;
|
||||
FaceId _faceId;
|
||||
|
||||
mutable int synthesized_flags;
|
||||
mutable QFixed lineWidth;
|
||||
mutable unsigned char *widthCache;
|
||||
mutable uint widthCacheSize;
|
||||
mutable QFixed *designAdvances;
|
||||
mutable int designAdvancesSize;
|
||||
|
||||
private:
|
||||
QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
|
||||
QImage::Format mask_format);
|
||||
|
||||
};
|
||||
|
||||
class QFontEngineMultiWin : public QFontEngineMulti
|
||||
{
|
||||
public:
|
||||
QFontEngineMultiWin(QFontEngine *first, const QStringList &fallbacks);
|
||||
void loadEngine(int at);
|
||||
|
||||
QStringList fallbacks;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QFONTENGINE_WIN_P_H
|
@ -1,408 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include "qguifunctions_wince.h"
|
||||
#include <shellapi.h>
|
||||
#include <QtCore/qlibrary.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
struct AygSHINITDLGINFO
|
||||
{
|
||||
DWORD dwMask;
|
||||
HWND hDlg;
|
||||
DWORD dwFlags;
|
||||
};
|
||||
|
||||
struct AygSIPINFO
|
||||
{
|
||||
DWORD cbSize;
|
||||
DWORD fdwFlags;
|
||||
RECT rcVisibleDesktop;
|
||||
RECT rcSipRect;
|
||||
DWORD dwImDataSize;
|
||||
void *pvImData;
|
||||
};
|
||||
|
||||
#ifndef SHIDIF_CANCELBUTTON
|
||||
#define SHIDIF_CANCELBUTTON 0x0080
|
||||
#endif
|
||||
|
||||
#ifndef SHIDIM_FLAGS
|
||||
#define SHIDIM_FLAGS 0x0001
|
||||
#endif
|
||||
|
||||
#ifndef SHIDIF_DONEBUTTON
|
||||
#define SHIDIF_DONEBUTTON 0x0001
|
||||
#endif
|
||||
#ifndef SHIDIF_SIZEDLGFULLSCREEN
|
||||
#define SHIDIF_SIZEDLGFULLSCREEN 0x0004
|
||||
#endif
|
||||
|
||||
#ifndef SHDB_HIDE
|
||||
#define SHDB_HIDE 0x0002
|
||||
#endif
|
||||
|
||||
#ifndef SHFS_SHOWTASKBAR
|
||||
#define SHFS_SHOWTASKBAR 0x0001
|
||||
#endif
|
||||
#ifndef SHFS_HIDETASKBAR
|
||||
#define SHFS_HIDETASKBAR 0x0002
|
||||
#endif
|
||||
#ifndef SHFS_SHOWSIPBUTTON
|
||||
#define SHFS_SHOWSIPBUTTON 0x0004
|
||||
#endif
|
||||
#ifndef SHFS_HIDESIPBUTTON
|
||||
#define SHFS_HIDESIPBUTTON 0x0008
|
||||
#endif
|
||||
#ifndef SHFS_SHOWSTARTICON
|
||||
#define SHFS_SHOWSTARTICON 0x0010
|
||||
#endif
|
||||
#ifndef SHFS_HIDESTARTICON
|
||||
#define SHFS_HIDESTARTICON 0x0020
|
||||
#endif
|
||||
|
||||
#ifndef SIPF_OFF
|
||||
#define SIPF_OFF 0x00000000
|
||||
#endif
|
||||
#ifndef SIPF_ON
|
||||
#define SIPF_ON 0x00000001
|
||||
#endif
|
||||
|
||||
#ifndef SPI_SETSIPINFO
|
||||
#define SPI_SETSIPINFO 224
|
||||
#endif
|
||||
#ifndef SPI_GETSIPINFO
|
||||
#define SPI_GETSIPINFO 225
|
||||
#endif
|
||||
#ifndef SPI_GETPLATFORMTYPE
|
||||
#define SPI_GETPLATFORMTYPE 257
|
||||
#endif
|
||||
|
||||
typedef BOOL (*AygInitDialog)(AygSHINITDLGINFO*);
|
||||
typedef BOOL (*AygFullScreen)(HWND, DWORD);
|
||||
typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT);
|
||||
typedef BOOL (*AygSHDoneButton)(HWND, DWORD);
|
||||
|
||||
static AygInitDialog ptrAygInitDialog = 0;
|
||||
static AygFullScreen ptrAygFullScreen = 0;
|
||||
static AygSHSipInfo ptrAygSHSipInfo = 0;
|
||||
static AygSHDoneButton ptrAygSHDoneButton = 0;
|
||||
static bool aygResolved = false;
|
||||
|
||||
static void resolveAygLibs()
|
||||
{
|
||||
if (!aygResolved) {
|
||||
aygResolved = true;
|
||||
QLibrary ayglib(QLatin1String("aygshell"));
|
||||
ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog");
|
||||
ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen");
|
||||
ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo");
|
||||
ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton");
|
||||
}
|
||||
}
|
||||
|
||||
int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint)
|
||||
{
|
||||
if (!lpvBits) {
|
||||
qWarning("::GetDIBits(), lpvBits NULL");
|
||||
return 0;
|
||||
}
|
||||
BITMAP bm;
|
||||
GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
|
||||
bm.bmHeight = qAbs(bm.bmHeight);
|
||||
|
||||
HBITMAP hTargetBitmap;
|
||||
void *pixels;
|
||||
|
||||
BITMAPINFO dibInfo;
|
||||
memset(&dibInfo, 0, sizeof(dibInfo));
|
||||
dibInfo.bmiHeader.biBitCount = 32;
|
||||
dibInfo.bmiHeader.biClrImportant = 0;
|
||||
dibInfo.bmiHeader.biClrUsed = 0;
|
||||
dibInfo.bmiHeader.biCompression = BI_RGB;;
|
||||
dibInfo.bmiHeader.biHeight = -bm.bmHeight;
|
||||
dibInfo.bmiHeader.biWidth = bm.bmWidth;
|
||||
dibInfo.bmiHeader.biPlanes = 1;
|
||||
dibInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
dibInfo.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
|
||||
|
||||
HDC displayDC = GetDC(NULL);
|
||||
if (!displayDC) {
|
||||
qWarning("::GetDIBits(), failed to GetDC");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = bm.bmHeight;
|
||||
|
||||
hTargetBitmap = CreateDIBSection(displayDC, (const BITMAPINFO*) &dibInfo, DIB_RGB_COLORS,
|
||||
(void**)&pixels, NULL, 0);
|
||||
if (!hTargetBitmap) {
|
||||
qWarning("::GetDIBits(), failed to CreateDIBSection");
|
||||
return 0;
|
||||
}
|
||||
|
||||
HDC hdcSrc = CreateCompatibleDC(displayDC);
|
||||
HDC hdcDst = CreateCompatibleDC(displayDC);
|
||||
|
||||
if (!(hdcDst && hdcSrc)) {
|
||||
qWarning("::GetDIBits(), failed to CreateCompatibleDC");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
HBITMAP hOldBitmap1 = (HBITMAP) SelectObject(hdcSrc, hSourceBitmap);
|
||||
HBITMAP hOldBitmap2 = (HBITMAP) SelectObject(hdcDst, hTargetBitmap);
|
||||
|
||||
if (!(hOldBitmap1 && hOldBitmap2)) {
|
||||
qWarning("::GetDIBits(), failed to SelectObject for bitmaps");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (!BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY)) {
|
||||
qWarning("::GetDIBits(), BitBlt failed");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
SelectObject(hdcSrc, hOldBitmap1);
|
||||
SelectObject(hdcDst, hOldBitmap2);
|
||||
|
||||
DeleteDC(hdcSrc);
|
||||
DeleteDC(hdcDst);
|
||||
|
||||
ReleaseDC(NULL, displayDC);
|
||||
|
||||
memcpy(lpvBits, pixels, dibInfo.bmiHeader.biSizeImage);
|
||||
|
||||
DeleteObject(hTargetBitmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd)
|
||||
{
|
||||
SHELLEXECUTEINFO info;
|
||||
info.hwnd = hwnd;
|
||||
info.lpVerb = L"Open";
|
||||
info.lpFile = file;
|
||||
info.lpParameters = params;
|
||||
info.lpDirectory = dir;
|
||||
info.nShow = showCmd;
|
||||
info.cbSize = sizeof(info);
|
||||
ShellExecuteEx(&info);
|
||||
return info.hInstApp;
|
||||
}
|
||||
|
||||
// Clipboard --------------------------------------------------------
|
||||
BOOL qt_wince_ChangeClipboardChain( HWND /*hWndRemove*/, HWND /*hWndNewNext*/ )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HWND qt_wince_SetClipboardViewer( HWND /*hWndNewViewer*/ )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// Graphics ---------------------------------------------------------
|
||||
COLORREF qt_wince_PALETTEINDEX( WORD /*wPaletteIndex*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Internal Qt -----------------------------------------------------
|
||||
bool qt_wince_is_platform(const QString &platformString) {
|
||||
wchar_t tszPlatform[64];
|
||||
if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(tszPlatform) / sizeof(wchar_t), tszPlatform, 0))
|
||||
if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int qt_wince_get_build()
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
if (GetVersionEx(&osvi)) {
|
||||
return osvi.dwBuildNumber;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qt_wince_get_version()
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
if (GetVersionEx(&osvi)) {
|
||||
return (osvi.dwMajorVersion * 10 + osvi.dwMinorVersion);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool qt_wince_is_windows_mobile_65()
|
||||
{
|
||||
const DWORD dwFirstWM65BuildNumber = 21139;
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
if (!GetVersionEx(&osvi))
|
||||
return false;
|
||||
return osvi.dwMajorVersion > 5
|
||||
|| (osvi.dwMajorVersion == 5 && (osvi.dwMinorVersion > 2 ||
|
||||
(osvi.dwMinorVersion == 2 && osvi.dwBuildNumber >= dwFirstWM65BuildNumber)));
|
||||
}
|
||||
|
||||
bool qt_wince_is_pocket_pc() {
|
||||
return qt_wince_is_platform(QString::fromLatin1("PocketPC"));
|
||||
}
|
||||
|
||||
bool qt_wince_is_smartphone() {
|
||||
return qt_wince_is_platform(QString::fromLatin1("Smartphone"));
|
||||
}
|
||||
bool qt_wince_is_mobile() {
|
||||
return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc());
|
||||
}
|
||||
|
||||
bool qt_wince_is_high_dpi() {
|
||||
if (!qt_wince_is_pocket_pc())
|
||||
return false;
|
||||
HDC deviceContext = GetDC(0);
|
||||
int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
|
||||
ReleaseDC(0, deviceContext);
|
||||
if ((dpi < 1000) && (dpi > 0))
|
||||
return dpi > 96;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void qt_wince_maximize(QWidget *widget)
|
||||
{
|
||||
HWND hwnd = widget->winId();
|
||||
if (qt_wince_is_mobile()) {
|
||||
AygSHINITDLGINFO shidi;
|
||||
shidi.dwMask = SHIDIM_FLAGS;
|
||||
shidi.hDlg = hwnd;
|
||||
shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
|
||||
if (widget->windowFlags() & Qt::WindowCancelButtonHint)
|
||||
shidi.dwFlags |= SHIDIF_CANCELBUTTON;
|
||||
if (widget->windowFlags() & Qt::WindowOkButtonHint)
|
||||
shidi.dwFlags |= SHIDIF_DONEBUTTON;
|
||||
if (!(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint)))
|
||||
shidi.dwFlags |= SHIDIF_CANCELBUTTON;
|
||||
resolveAygLibs();
|
||||
if (ptrAygInitDialog)
|
||||
ptrAygInitDialog(&shidi);
|
||||
} else {
|
||||
RECT r;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
|
||||
MoveWindow(hwnd, r.top, r.left, r.right - r.left, r.bottom - r.top, true);
|
||||
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG);
|
||||
}
|
||||
}
|
||||
|
||||
void qt_wince_unmaximize(QWidget *widget)
|
||||
{
|
||||
if (ptrAygSHDoneButton && qt_wince_is_mobile()
|
||||
&& !(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint)))
|
||||
{
|
||||
// Hide the [X] button, we've added in qt_wince_maximize.
|
||||
ptrAygSHDoneButton(widget->winId(), SHDB_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
void qt_wince_minimize(HWND hwnd)
|
||||
{
|
||||
#ifdef Q_OS_WINCE_WM
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
#else
|
||||
if (!IsWindowVisible(hwnd)) {
|
||||
// Hack for an initial showMinimized.
|
||||
// Without it, our widget doesn't appear in the task bar.
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
}
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void qt_wince_hide_taskbar(HWND hwnd) {
|
||||
if (ptrAygFullScreen)
|
||||
ptrAygFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
|
||||
}
|
||||
|
||||
void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf) {
|
||||
resolveAygLibs();
|
||||
if (fullScreen) {
|
||||
QRect r = qApp->desktop()->screenGeometry(QWidget::find(hwnd));
|
||||
SetWindowPos(hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
|
||||
if (ptrAygFullScreen)
|
||||
ptrAygFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
|
||||
if (!qt_wince_is_mobile()) {
|
||||
HWND handle = FindWindow(L"HHTaskBar", L"");
|
||||
if (handle) {
|
||||
ShowWindow(handle, 0);
|
||||
EnableWindow(handle, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ptrAygFullScreen)
|
||||
ptrAygFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON | SHFS_SHOWSTARTICON);
|
||||
SetWindowPos(hwnd, 0, 0, 0, 0, 0, swpf);
|
||||
if (!qt_wince_is_mobile()) {
|
||||
HWND handle = FindWindow(L"HHTaskBar", L"");
|
||||
if (handle) {
|
||||
ShowWindow(handle, 1);
|
||||
EnableWindow(handle, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void qt_wince_show_SIP(bool show)
|
||||
{
|
||||
resolveAygLibs();
|
||||
if (!ptrAygSHSipInfo)
|
||||
return;
|
||||
|
||||
AygSIPINFO si;
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cbSize = sizeof(si);
|
||||
ptrAygSHSipInfo(SPI_GETSIPINFO, 0, &si, 0);
|
||||
si.cbSize = sizeof(si);
|
||||
si.fdwFlags = (show ? SIPF_ON : SIPF_OFF);
|
||||
ptrAygSHSipInfo(SPI_SETSIPINFO, 0, &si, 0);
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef QGUIFUNCTIONS_WCE_H
|
||||
#define QGUIFUNCTIONS_WCE_H
|
||||
#ifdef Q_OS_WINCE
|
||||
#include <QtCore/qfunctions_wince.h>
|
||||
#define UNDER_NT
|
||||
#include <wingdi.h>
|
||||
|
||||
#ifdef QT_BUILD_GUI_LIB
|
||||
QT_BEGIN_HEADER
|
||||
QT_BEGIN_NAMESPACE
|
||||
QT_MODULE(Gui)
|
||||
QT_END_NAMESPACE
|
||||
QT_END_HEADER
|
||||
#endif
|
||||
|
||||
// application defines
|
||||
#define SPI_SETNONCLIENTMETRICS 72
|
||||
#define SPI_SETICONTITLELOGFONT 0x0022
|
||||
#define WM_ACTIVATEAPP 0x001c
|
||||
#define SW_PARENTCLOSING 1
|
||||
#define SW_OTHERMAXIMIZED 2
|
||||
#define SW_PARENTOPENING 3
|
||||
#define SW_OTHERRESTORED 4
|
||||
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
|
||||
|
||||
// drag n drop
|
||||
#ifndef CFSTR_PERFORMEDDROPEFFECT
|
||||
#define CFSTR_PERFORMEDDROPEFFECT TEXT("Performed DropEffect")
|
||||
#endif
|
||||
int qt_wince_GetDIBits(HDC, HBITMAP, uint, uint, void*, LPBITMAPINFO, uint);
|
||||
#define GetDIBits(a,b,c,d,e,f,g) qt_wince_GetDIBits(a,b,c,d,e,f,g)
|
||||
|
||||
// QWidget
|
||||
#define SW_SHOWMINIMIZED SW_MINIMIZE
|
||||
|
||||
// QRegion
|
||||
#define ALTERNATE 0
|
||||
#define WINDING 1
|
||||
|
||||
// QFontEngine
|
||||
typedef struct _FIXED {
|
||||
WORD fract;
|
||||
short value;
|
||||
} FIXED;
|
||||
|
||||
typedef struct tagPOINTFX {
|
||||
FIXED x;
|
||||
FIXED y;
|
||||
} POINTFX;
|
||||
|
||||
typedef struct _MAT2 {
|
||||
FIXED eM11;
|
||||
FIXED eM12;
|
||||
FIXED eM21;
|
||||
FIXED eM22;
|
||||
} MAT2;
|
||||
|
||||
typedef struct _GLYPHMETRICS {
|
||||
UINT gmBlackBoxX;
|
||||
UINT gmBlackBoxY;
|
||||
POINT gmptGlyphOrigin;
|
||||
short gmCellIncX;
|
||||
short gmCellIncY;
|
||||
} GLYPHMETRICS;
|
||||
|
||||
typedef struct tagTTPOLYGONHEADER
|
||||
{
|
||||
DWORD cb;
|
||||
DWORD dwType;
|
||||
POINTFX pfxStart;
|
||||
} TTPOLYGONHEADER;
|
||||
|
||||
typedef struct tagTTPOLYCURVE
|
||||
{
|
||||
WORD wType;
|
||||
WORD cpfx;
|
||||
POINTFX apfx[1];
|
||||
} TTPOLYCURVE;
|
||||
|
||||
#define GGO_NATIVE 2
|
||||
#define GGO_GLYPH_INDEX 0x0080
|
||||
#define TT_PRIM_LINE 1
|
||||
#define TT_PRIM_QSPLINE 2
|
||||
#define TT_PRIM_CSPLINE 3
|
||||
#define ANSI_VAR_FONT 12
|
||||
|
||||
HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR operation, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd);
|
||||
#define ShellExecute(a,b,c,d,e,f) qt_wince_ShellExecute(a,b,c,d,e,f)
|
||||
|
||||
|
||||
// Clipboard --------------------------------------------------------
|
||||
#define WM_CHANGECBCHAIN 1
|
||||
#define WM_DRAWCLIPBOARD 2
|
||||
|
||||
BOOL qt_wince_ChangeClipboardChain(
|
||||
HWND hWndRemove, // handle to window to remove
|
||||
HWND hWndNewNext // handle to next window
|
||||
);
|
||||
#define ChangeClipboardChain(a,b) qt_wince_ChangeClipboardChain(a,b);
|
||||
|
||||
HWND qt_wince_SetClipboardViewer(
|
||||
HWND hWndNewViewer // handle to clipboard viewer window
|
||||
);
|
||||
#define SetClipboardViewer(a) qt_wince_SetClipboardViewer(a)
|
||||
|
||||
// Graphics ---------------------------------------------------------
|
||||
COLORREF qt_wince_PALETTEINDEX( WORD wPaletteIndex );
|
||||
#define PALETTEINDEX(a) qt_wince_PALETTEINDEX(a)
|
||||
|
||||
#endif // Q_OS_WINCE
|
||||
#endif // QGUIFUNCTIONS_WCE_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,255 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdnd_p.h"
|
||||
|
||||
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
#include <shlobj.h>
|
||||
#include "qguifunctions_wince.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QOleEnumFmtEtc::QOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs)
|
||||
{
|
||||
m_isNull = false;
|
||||
m_dwRefs = 1;
|
||||
m_nIndex = 0;
|
||||
|
||||
for (int idx = 0; idx < fmtetcs.count(); ++idx) {
|
||||
LPFORMATETC destetc = new FORMATETC();
|
||||
if (copyFormatEtc(destetc, (LPFORMATETC)&(fmtetcs.at(idx)))) {
|
||||
m_lpfmtetcs.append(destetc);
|
||||
} else {
|
||||
m_isNull = true;
|
||||
delete destetc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QOleEnumFmtEtc::QOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs)
|
||||
{
|
||||
m_isNull = false;
|
||||
m_dwRefs = 1;
|
||||
m_nIndex = 0;
|
||||
|
||||
for (int idx = 0; idx < lpfmtetcs.count(); ++idx) {
|
||||
LPFORMATETC srcetc = lpfmtetcs.at(idx);
|
||||
LPFORMATETC destetc = new FORMATETC();
|
||||
if (copyFormatEtc(destetc, srcetc)) {
|
||||
m_lpfmtetcs.append(destetc);
|
||||
} else {
|
||||
m_isNull = true;
|
||||
delete destetc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QOleEnumFmtEtc::~QOleEnumFmtEtc()
|
||||
{
|
||||
LPMALLOC pmalloc;
|
||||
|
||||
#if !defined(Q_OS_WINCE)
|
||||
if (CoGetMalloc(MEMCTX_TASK, &pmalloc) == NOERROR) {
|
||||
#else
|
||||
if (SHGetMalloc(&pmalloc) == NOERROR) {
|
||||
#endif
|
||||
for (int idx = 0; idx < m_lpfmtetcs.count(); ++idx) {
|
||||
LPFORMATETC tmpetc = m_lpfmtetcs.at(idx);
|
||||
if (tmpetc->ptd)
|
||||
pmalloc->Free(tmpetc->ptd);
|
||||
delete tmpetc;
|
||||
}
|
||||
|
||||
pmalloc->Release();
|
||||
}
|
||||
m_lpfmtetcs.clear();
|
||||
}
|
||||
|
||||
bool QOleEnumFmtEtc::isNull() const
|
||||
{
|
||||
return m_isNull;
|
||||
}
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHODIMP
|
||||
QOleEnumFmtEtc::QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
|
||||
{
|
||||
if (riid == IID_IUnknown || riid == IID_IEnumFORMATETC) {
|
||||
*ppvObj = this;
|
||||
AddRef();
|
||||
return NOERROR;
|
||||
}
|
||||
*ppvObj = NULL;
|
||||
return ResultFromScode(E_NOINTERFACE);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QOleEnumFmtEtc::AddRef(void)
|
||||
{
|
||||
return ++m_dwRefs;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG)
|
||||
QOleEnumFmtEtc::Release(void)
|
||||
{
|
||||
if (--m_dwRefs == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_dwRefs;
|
||||
}
|
||||
|
||||
// IEnumFORMATETC methods
|
||||
STDMETHODIMP
|
||||
QOleEnumFmtEtc::Next(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched)
|
||||
{
|
||||
ULONG i=0;
|
||||
ULONG nOffset;
|
||||
|
||||
if (rgelt == NULL)
|
||||
return ResultFromScode(E_INVALIDARG);
|
||||
|
||||
while (i < celt) {
|
||||
nOffset = m_nIndex + i;
|
||||
|
||||
if (nOffset < ULONG(m_lpfmtetcs.count())) {
|
||||
copyFormatEtc((LPFORMATETC)&(rgelt[i]), m_lpfmtetcs.at(nOffset));
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_nIndex += (WORD)i;
|
||||
|
||||
if (pceltFetched != NULL)
|
||||
*pceltFetched = i;
|
||||
|
||||
if (i != celt)
|
||||
return ResultFromScode(S_FALSE);
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
QOleEnumFmtEtc::Skip(ULONG celt)
|
||||
{
|
||||
ULONG i=0;
|
||||
ULONG nOffset;
|
||||
|
||||
while (i < celt) {
|
||||
nOffset = m_nIndex + i;
|
||||
|
||||
if (nOffset < ULONG(m_lpfmtetcs.count())) {
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_nIndex += (WORD)i;
|
||||
|
||||
if (i != celt)
|
||||
return ResultFromScode(S_FALSE);
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
QOleEnumFmtEtc::Reset()
|
||||
{
|
||||
m_nIndex = 0;
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
QOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum)
|
||||
{
|
||||
if (newEnum == NULL)
|
||||
return ResultFromScode(E_INVALIDARG);
|
||||
|
||||
QOleEnumFmtEtc *result = new QOleEnumFmtEtc(m_lpfmtetcs);
|
||||
result->m_nIndex = m_nIndex;
|
||||
|
||||
if (result->isNull()) {
|
||||
delete result;
|
||||
return ResultFromScode(E_OUTOFMEMORY);
|
||||
} else {
|
||||
*newEnum = result;
|
||||
}
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
bool QOleEnumFmtEtc::copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const
|
||||
{
|
||||
if (dest == NULL || src == NULL)
|
||||
return false;
|
||||
|
||||
*dest = *src;
|
||||
|
||||
if (src->ptd) {
|
||||
LPVOID pout;
|
||||
LPMALLOC pmalloc;
|
||||
|
||||
#if !defined(Q_OS_WINCE)
|
||||
if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR)
|
||||
#else
|
||||
if (SHGetMalloc(&pmalloc) != NOERROR)
|
||||
#endif
|
||||
return false;
|
||||
|
||||
pout = (LPVOID)pmalloc->Alloc(src->ptd->tdSize);
|
||||
memcpy(dest->ptd, src->ptd, size_t(src->ptd->tdSize));
|
||||
|
||||
pmalloc->Release();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
|
@ -1,62 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qpaintdevice.h"
|
||||
#include "qpainter.h"
|
||||
#include "qwidget.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qapplication.h"
|
||||
#include <private/qapplication_p.h>
|
||||
#include "qt_windows.h"
|
||||
#include "qprinter.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
HDC QPaintDevice::getDC() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QPaintDevice::releaseDC(HDC) const
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,477 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qpixmap.h"
|
||||
#include "qpixmap_raster_p.h"
|
||||
|
||||
#include "qbitmap.h"
|
||||
#include "qimage.h"
|
||||
#include "qwidget.h"
|
||||
#include "qpainter.h"
|
||||
#include "qdatastream.h"
|
||||
#include "qbuffer.h"
|
||||
#include "qapplication.h"
|
||||
#include "qevent.h"
|
||||
#include "qfile.h"
|
||||
#include "qfileinfo.h"
|
||||
#include "qdatetime.h"
|
||||
#include "qpixmapcache.h"
|
||||
#include "qimagereader.h"
|
||||
#include "qimagewriter.h"
|
||||
#include "qdebug.h"
|
||||
#include "qt_windows.h"
|
||||
|
||||
#if defined(Q_WS_WINCE)
|
||||
#include <winbase.h>
|
||||
#include "qguifunctions_wince.h"
|
||||
extern bool qt_wince_is_high_dpi();
|
||||
extern bool qt_wince_is_pocket_pc();
|
||||
#endif
|
||||
|
||||
#ifndef CAPTUREBLT
|
||||
#define CAPTUREBLT ((DWORD)0x40000000)
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
|
||||
{
|
||||
RECT r;
|
||||
GetClientRect(winId, &r);
|
||||
|
||||
if (w < 0) w = r.right - r.left;
|
||||
if (h < 0) h = r.bottom - r.top;
|
||||
|
||||
#ifdef Q_WS_WINCE_WM
|
||||
if (qt_wince_is_pocket_pc()) {
|
||||
QWidget *widget = QWidget::find(winId);
|
||||
if (qobject_cast<QDesktopWidget *>(widget)) {
|
||||
RECT rect = {0,0,0,0};
|
||||
AdjustWindowRectEx(&rect, WS_BORDER | WS_CAPTION, FALSE, 0);
|
||||
int magicNumber = qt_wince_is_high_dpi() ? 4 : 2;
|
||||
y += rect.top - magicNumber;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create and setup bitmap
|
||||
HDC display_dc = GetDC(0);
|
||||
HDC bitmap_dc = CreateCompatibleDC(display_dc);
|
||||
HBITMAP bitmap = CreateCompatibleBitmap(display_dc, w, h);
|
||||
HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);
|
||||
|
||||
// copy data
|
||||
HDC window_dc = GetDC(winId);
|
||||
BitBlt(bitmap_dc, 0, 0, w, h, window_dc, x, y, SRCCOPY
|
||||
#ifndef Q_WS_WINCE
|
||||
| CAPTUREBLT
|
||||
#endif
|
||||
);
|
||||
|
||||
// clean up all but bitmap
|
||||
ReleaseDC(winId, window_dc);
|
||||
SelectObject(bitmap_dc, null_bitmap);
|
||||
DeleteDC(bitmap_dc);
|
||||
|
||||
QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap);
|
||||
|
||||
DeleteObject(bitmap);
|
||||
ReleaseDC(0, display_dc);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
|
||||
{
|
||||
if (isNull())
|
||||
return 0;
|
||||
|
||||
HBITMAP bitmap = 0;
|
||||
if (data->classId() == QPlatformPixmap::RasterClass) {
|
||||
QRasterPlatformPixmap* d = static_cast<QRasterPlatformPixmap*>(data.data());
|
||||
int w = d->image.width();
|
||||
int h = d->image.height();
|
||||
|
||||
HDC display_dc = GetDC(0);
|
||||
|
||||
// Define the header
|
||||
BITMAPINFO bmi;
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = w;
|
||||
bmi.bmiHeader.biHeight = -h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
// Create the pixmap
|
||||
uchar *pixels = 0;
|
||||
bitmap = CreateDIBSection(display_dc, &bmi, DIB_RGB_COLORS, (void **) &pixels, 0, 0);
|
||||
ReleaseDC(0, display_dc);
|
||||
if (!bitmap) {
|
||||
qErrnoWarning("QPixmap::toWinHBITMAP(), failed to create dibsection");
|
||||
return 0;
|
||||
}
|
||||
if (!pixels) {
|
||||
qErrnoWarning("QPixmap::toWinHBITMAP(), did not allocate pixel data");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Copy over the data
|
||||
QImage::Format imageFormat = QImage::Format_ARGB32;
|
||||
if (format == NoAlpha)
|
||||
imageFormat = QImage::Format_RGB32;
|
||||
else if (format == PremultipliedAlpha)
|
||||
imageFormat = QImage::Format_ARGB32_Premultiplied;
|
||||
const QImage image = d->image.convertToFormat(imageFormat);
|
||||
int bytes_per_line = w * 4;
|
||||
for (int y=0; y<h; ++y)
|
||||
memcpy(pixels + y * bytes_per_line, image.scanLine(y), bytes_per_line);
|
||||
|
||||
} else {
|
||||
QPlatformPixmap *data = new QRasterPlatformPixmap(depth() == 1 ?
|
||||
QPlatformPixmap::BitmapType : QPlatformPixmap::PixmapType);
|
||||
data->fromImage(toImage(), Qt::AutoColor);
|
||||
return QPixmap(data).toWinHBITMAP(format);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
|
||||
{
|
||||
// Verify size
|
||||
BITMAP bitmap_info;
|
||||
memset(&bitmap_info, 0, sizeof(BITMAP));
|
||||
|
||||
int res = GetObject(bitmap, sizeof(BITMAP), &bitmap_info);
|
||||
if (!res) {
|
||||
qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info");
|
||||
return QPixmap();
|
||||
}
|
||||
int w = bitmap_info.bmWidth;
|
||||
int h = bitmap_info.bmHeight;
|
||||
|
||||
BITMAPINFO bmi;
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = w;
|
||||
bmi.bmiHeader.biHeight = -h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
QImage result;
|
||||
// Get bitmap bits
|
||||
uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
|
||||
|
||||
HDC display_dc = GetDC(0);
|
||||
if (GetDIBits(display_dc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
|
||||
|
||||
QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied;
|
||||
uint mask = 0;
|
||||
if (format == NoAlpha) {
|
||||
imageFormat = QImage::Format_RGB32;
|
||||
mask = 0xff000000;
|
||||
}
|
||||
|
||||
// Create image and copy data into image.
|
||||
QImage image(w, h, imageFormat);
|
||||
if (!image.isNull()) { // failed to alloc?
|
||||
int bytes_per_line = w * sizeof(QRgb);
|
||||
for (int y=0; y<h; ++y) {
|
||||
QRgb *dest = (QRgb *) image.scanLine(y);
|
||||
const QRgb *src = (const QRgb *) (data + y * bytes_per_line);
|
||||
for (int x=0; x<w; ++x) {
|
||||
const uint pixel = src[x];
|
||||
if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0)
|
||||
dest[x] = pixel | 0xff000000;
|
||||
else
|
||||
dest[x] = pixel | mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = image;
|
||||
} else {
|
||||
qWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap bits");
|
||||
}
|
||||
ReleaseDC(0, display_dc);
|
||||
qFree(data);
|
||||
return fromImage(result);
|
||||
}
|
||||
|
||||
HBITMAP qt_createIconMask(const QBitmap &bitmap)
|
||||
{
|
||||
QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
|
||||
int w = bm.width();
|
||||
int h = bm.height();
|
||||
int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
|
||||
uchar *bits = new uchar[bpl*h];
|
||||
bm.invertPixels();
|
||||
for (int y=0; y<h; y++)
|
||||
memcpy(bits+y*bpl, bm.scanLine(y), bpl);
|
||||
HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
|
||||
delete [] bits;
|
||||
return hbm;
|
||||
}
|
||||
|
||||
HICON QPixmap::toWinHICON() const
|
||||
{
|
||||
QBitmap maskBitmap = mask();
|
||||
if (maskBitmap.isNull()) {
|
||||
maskBitmap= QBitmap(size());
|
||||
maskBitmap.fill(Qt::color1);
|
||||
}
|
||||
|
||||
ICONINFO ii;
|
||||
ii.fIcon = true;
|
||||
ii.hbmMask = qt_createIconMask(maskBitmap);
|
||||
ii.hbmColor = toWinHBITMAP(QPixmap::Alpha);
|
||||
ii.xHotspot = 0;
|
||||
ii.yHotspot = 0;
|
||||
|
||||
HICON hIcon = CreateIconIndirect(&ii);
|
||||
|
||||
DeleteObject(ii.hbmColor);
|
||||
DeleteObject(ii.hbmMask);
|
||||
|
||||
return hIcon;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifndef Q_WS_WINCE
|
||||
|
||||
static QImage qt_fromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
|
||||
{
|
||||
BITMAPINFO bmi;
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = w;
|
||||
bmi.bmiHeader.biHeight = -h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
|
||||
if (image.isNull())
|
||||
return image;
|
||||
|
||||
// Get bitmap bits
|
||||
uchar *data = (uchar *) qMalloc(bmi.bmiHeader.biSizeImage);
|
||||
|
||||
if (GetDIBits(hdc, bitmap, 0, h, data, &bmi, DIB_RGB_COLORS)) {
|
||||
// Create image and copy data into image.
|
||||
for (int y=0; y<h; ++y) {
|
||||
void *dest = (void *) image.scanLine(y);
|
||||
void *src = data + y * image.bytesPerLine();
|
||||
memcpy(dest, src, image.bytesPerLine());
|
||||
}
|
||||
} else {
|
||||
qWarning("qt_fromWinHBITMAP(), failed to get bitmap bits");
|
||||
}
|
||||
qFree(data);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
QPixmap QPixmap::fromWinHICON(HICON icon)
|
||||
{
|
||||
bool foundAlpha = false;
|
||||
HDC screenDevice = GetDC(0);
|
||||
HDC hdc = CreateCompatibleDC(screenDevice);
|
||||
ReleaseDC(0, screenDevice);
|
||||
|
||||
ICONINFO iconinfo;
|
||||
bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
|
||||
if (!result)
|
||||
qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
|
||||
|
||||
int w = iconinfo.xHotspot * 2;
|
||||
int h = iconinfo.yHotspot * 2;
|
||||
|
||||
BITMAPINFOHEADER bitmapInfo;
|
||||
bitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bitmapInfo.biWidth = w;
|
||||
bitmapInfo.biHeight = h;
|
||||
bitmapInfo.biPlanes = 1;
|
||||
bitmapInfo.biBitCount = 32;
|
||||
bitmapInfo.biCompression = BI_RGB;
|
||||
bitmapInfo.biSizeImage = 0;
|
||||
bitmapInfo.biXPelsPerMeter = 0;
|
||||
bitmapInfo.biYPelsPerMeter = 0;
|
||||
bitmapInfo.biClrUsed = 0;
|
||||
bitmapInfo.biClrImportant = 0;
|
||||
DWORD* bits;
|
||||
|
||||
HBITMAP winBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bitmapInfo, DIB_RGB_COLORS, (VOID**)&bits, NULL, 0);
|
||||
HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
|
||||
DrawIconEx( hdc, 0, 0, icon, iconinfo.xHotspot * 2, iconinfo.yHotspot * 2, 0, 0, DI_NORMAL);
|
||||
QImage image = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
|
||||
|
||||
for (int y = 0 ; y < h && !foundAlpha ; y++) {
|
||||
QRgb *scanLine= reinterpret_cast<QRgb *>(image.scanLine(y));
|
||||
for (int x = 0; x < w ; x++) {
|
||||
if (qAlpha(scanLine[x]) != 0) {
|
||||
foundAlpha = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!foundAlpha) {
|
||||
//If no alpha was found, we use the mask to set alpha values
|
||||
DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK);
|
||||
QImage mask = qt_fromWinHBITMAP(hdc, winBitmap, w, h);
|
||||
|
||||
for (int y = 0 ; y < h ; y++){
|
||||
QRgb *scanlineImage = reinterpret_cast<QRgb *>(image.scanLine(y));
|
||||
QRgb *scanlineMask = mask.isNull() ? 0 : reinterpret_cast<QRgb *>(mask.scanLine(y));
|
||||
for (int x = 0; x < w ; x++){
|
||||
if (scanlineMask && qRed(scanlineMask[x]) != 0)
|
||||
scanlineImage[x] = 0; //mask out this pixel
|
||||
else
|
||||
scanlineImage[x] |= 0xff000000; // set the alpha channel to 255
|
||||
}
|
||||
}
|
||||
}
|
||||
//dispose resources created by iconinfo call
|
||||
DeleteObject(iconinfo.hbmMask);
|
||||
DeleteObject(iconinfo.hbmColor);
|
||||
|
||||
SelectObject(hdc, oldhdc); //restore state
|
||||
DeleteObject(winBitmap);
|
||||
DeleteDC(hdc);
|
||||
return QPixmap::fromImage(image);
|
||||
}
|
||||
#else //ifndef Q_WS_WINCE
|
||||
QPixmap QPixmap::fromWinHICON(HICON icon)
|
||||
{
|
||||
HDC screenDevice = GetDC(0);
|
||||
HDC hdc = CreateCompatibleDC(screenDevice);
|
||||
ReleaseDC(0, screenDevice);
|
||||
|
||||
ICONINFO iconinfo;
|
||||
bool result = GetIconInfo(icon, &iconinfo);
|
||||
if (!result)
|
||||
qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
|
||||
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
if (!iconinfo.xHotspot || !iconinfo.yHotspot) {
|
||||
// We could not retrieve the icon size via GetIconInfo,
|
||||
// so we try again using the icon bitmap.
|
||||
BITMAP bm;
|
||||
int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm);
|
||||
if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm);
|
||||
if (!result) {
|
||||
qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size");
|
||||
return QPixmap();
|
||||
}
|
||||
w = bm.bmWidth;
|
||||
h = bm.bmHeight;
|
||||
} else {
|
||||
// x and y Hotspot describes the icon center
|
||||
w = iconinfo.xHotspot * 2;
|
||||
h = iconinfo.yHotspot * 2;
|
||||
}
|
||||
const DWORD dwImageSize = w * h * 4;
|
||||
|
||||
BITMAPINFO bmi;
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
|
||||
bmi.bmiHeader.biWidth = w;
|
||||
bmi.bmiHeader.biHeight = -h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = dwImageSize;
|
||||
|
||||
uchar* bits;
|
||||
|
||||
HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0);
|
||||
if (winBitmap )
|
||||
memset(bits, 0xff, dwImageSize);
|
||||
if (!winBitmap) {
|
||||
qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()");
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
|
||||
if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL))
|
||||
qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
|
||||
|
||||
uint mask = 0xff000000;
|
||||
// Create image and copy data into image.
|
||||
QImage image(w, h, QImage::Format_ARGB32);
|
||||
|
||||
if (!image.isNull()) { // failed to alloc?
|
||||
int bytes_per_line = w * sizeof(QRgb);
|
||||
for (int y=0; y < h; ++y) {
|
||||
QRgb *dest = (QRgb *) image.scanLine(y);
|
||||
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
|
||||
for (int x=0; x < w; ++x) {
|
||||
dest[x] = src[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK))
|
||||
qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
|
||||
if (!image.isNull()) { // failed to alloc?
|
||||
int bytes_per_line = w * sizeof(QRgb);
|
||||
for (int y=0; y < h; ++y) {
|
||||
QRgb *dest = (QRgb *) image.scanLine(y);
|
||||
const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
|
||||
for (int x=0; x < w; ++x) {
|
||||
if (!src[x])
|
||||
dest[x] = dest[x] | mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectObject(hdc, oldhdc); //restore state
|
||||
DeleteObject(winBitmap);
|
||||
DeleteDC(hdc);
|
||||
return QPixmap::fromImage(image);
|
||||
}
|
||||
#endif //ifndef Q_WS_WINCE
|
||||
#endif //ifdef Q_WS_WIN
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,709 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qrawfont_p.h"
|
||||
#include <private/qsystemlibrary_p.h>
|
||||
|
||||
#if !defined(QT_NO_DIRECTWRITE)
|
||||
# include "qfontenginedirectwrite_p.h"
|
||||
# include <dwrite.h>
|
||||
#endif
|
||||
|
||||
#if !defined(QT_NO_RAWFONT)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
struct BigEndian
|
||||
{
|
||||
quint8 data[sizeof(T)];
|
||||
|
||||
operator T() const
|
||||
{
|
||||
T littleEndian = 0;
|
||||
for (int i=0; i<sizeof(T); ++i) {
|
||||
littleEndian |= data[i] << ((sizeof(T) - i - 1) * 8);
|
||||
}
|
||||
|
||||
return littleEndian;
|
||||
}
|
||||
|
||||
BigEndian<T> &operator=(const T &t)
|
||||
{
|
||||
for (int i=0; i<sizeof(T); ++i) {
|
||||
data[i] = ((t >> (sizeof(T) - i - 1) * 8) & 0xff);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
# pragma pack(1)
|
||||
|
||||
// Common structure for all formats of the "name" table
|
||||
struct NameTable
|
||||
{
|
||||
BigEndian<quint16> format;
|
||||
BigEndian<quint16> count;
|
||||
BigEndian<quint16> stringOffset;
|
||||
};
|
||||
|
||||
struct NameRecord
|
||||
{
|
||||
BigEndian<quint16> platformID;
|
||||
BigEndian<quint16> encodingID;
|
||||
BigEndian<quint16> languageID;
|
||||
BigEndian<quint16> nameID;
|
||||
BigEndian<quint16> length;
|
||||
BigEndian<quint16> offset;
|
||||
};
|
||||
|
||||
struct OffsetSubTable
|
||||
{
|
||||
BigEndian<quint32> scalerType;
|
||||
BigEndian<quint16> numTables;
|
||||
BigEndian<quint16> searchRange;
|
||||
BigEndian<quint16> entrySelector;
|
||||
BigEndian<quint16> rangeShift;
|
||||
};
|
||||
|
||||
struct TableDirectory
|
||||
{
|
||||
BigEndian<quint32> identifier;
|
||||
BigEndian<quint32> checkSum;
|
||||
BigEndian<quint32> offset;
|
||||
BigEndian<quint32> length;
|
||||
};
|
||||
|
||||
struct OS2Table
|
||||
{
|
||||
BigEndian<quint16> version;
|
||||
BigEndian<qint16> avgCharWidth;
|
||||
BigEndian<quint16> weightClass;
|
||||
BigEndian<quint16> widthClass;
|
||||
BigEndian<quint16> type;
|
||||
BigEndian<qint16> subscriptXSize;
|
||||
BigEndian<qint16> subscriptYSize;
|
||||
BigEndian<qint16> subscriptXOffset;
|
||||
BigEndian<qint16> subscriptYOffset;
|
||||
BigEndian<qint16> superscriptXSize;
|
||||
BigEndian<qint16> superscriptYSize;
|
||||
BigEndian<qint16> superscriptXOffset;
|
||||
BigEndian<qint16> superscriptYOffset;
|
||||
BigEndian<qint16> strikeOutSize;
|
||||
BigEndian<qint16> strikeOutPosition;
|
||||
BigEndian<qint16> familyClass;
|
||||
quint8 panose[10];
|
||||
BigEndian<quint32> unicodeRanges[4];
|
||||
quint8 vendorID[4];
|
||||
BigEndian<quint16> selection;
|
||||
BigEndian<quint16> firstCharIndex;
|
||||
BigEndian<quint16> lastCharIndex;
|
||||
BigEndian<qint16> typoAscender;
|
||||
BigEndian<qint16> typoDescender;
|
||||
BigEndian<qint16> typoLineGap;
|
||||
BigEndian<quint16> winAscent;
|
||||
BigEndian<quint16> winDescent;
|
||||
BigEndian<quint32> codepageRanges[2];
|
||||
BigEndian<qint16> height;
|
||||
BigEndian<qint16> capHeight;
|
||||
BigEndian<quint16> defaultChar;
|
||||
BigEndian<quint16> breakChar;
|
||||
BigEndian<quint16> maxContext;
|
||||
};
|
||||
|
||||
# pragma pack()
|
||||
|
||||
class EmbeddedFont
|
||||
{
|
||||
public:
|
||||
EmbeddedFont(const QByteArray &fontData);
|
||||
|
||||
QString changeFamilyName(const QString &newFamilyName);
|
||||
QByteArray data() const { return m_fontData; }
|
||||
TableDirectory *tableDirectoryEntry(const QByteArray &tagName);
|
||||
QString familyName(TableDirectory *nameTableDirectory = 0);
|
||||
|
||||
private:
|
||||
QByteArray m_fontData;
|
||||
};
|
||||
|
||||
EmbeddedFont::EmbeddedFont(const QByteArray &fontData) : m_fontData(fontData)
|
||||
{
|
||||
}
|
||||
|
||||
TableDirectory *EmbeddedFont::tableDirectoryEntry(const QByteArray &tagName)
|
||||
{
|
||||
Q_ASSERT(tagName.size() == 4);
|
||||
|
||||
const BigEndian<quint32> *tagIdPtr =
|
||||
reinterpret_cast<const BigEndian<quint32> *>(tagName.constData());
|
||||
quint32 tagId = *tagIdPtr;
|
||||
|
||||
OffsetSubTable *offsetSubTable = reinterpret_cast<OffsetSubTable *>(m_fontData.data());
|
||||
TableDirectory *tableDirectory = reinterpret_cast<TableDirectory *>(offsetSubTable + 1);
|
||||
|
||||
TableDirectory *nameTableDirectoryEntry = 0;
|
||||
for (int i=0; i<offsetSubTable->numTables; ++i, ++tableDirectory) {
|
||||
if (tableDirectory->identifier == tagId) {
|
||||
nameTableDirectoryEntry = tableDirectory;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nameTableDirectoryEntry;
|
||||
}
|
||||
|
||||
QString EmbeddedFont::familyName(TableDirectory *nameTableDirectoryEntry)
|
||||
{
|
||||
QString name;
|
||||
|
||||
if (nameTableDirectoryEntry == 0)
|
||||
nameTableDirectoryEntry = tableDirectoryEntry("name");
|
||||
|
||||
if (nameTableDirectoryEntry != 0) {
|
||||
NameTable *nameTable = reinterpret_cast<NameTable *>(m_fontData.data()
|
||||
+ nameTableDirectoryEntry->offset);
|
||||
NameRecord *nameRecord = reinterpret_cast<NameRecord *>(nameTable + 1);
|
||||
for (int i=0; i<nameTable->count; ++i, ++nameRecord) {
|
||||
if (nameRecord->nameID == 1
|
||||
&& nameRecord->platformID == 3 // Windows
|
||||
&& nameRecord->languageID == 0x0409) { // US English
|
||||
const void *ptr = reinterpret_cast<const quint8 *>(nameTable)
|
||||
+ nameTable->stringOffset
|
||||
+ nameRecord->offset;
|
||||
|
||||
const BigEndian<quint16> *s = reinterpret_cast<const BigEndian<quint16> *>(ptr);
|
||||
for (int j=0; j<nameRecord->length / sizeof(quint16); ++j)
|
||||
name += QChar(s[j]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QString EmbeddedFont::changeFamilyName(const QString &newFamilyName)
|
||||
{
|
||||
TableDirectory *nameTableDirectoryEntry = tableDirectoryEntry("name");
|
||||
if (nameTableDirectoryEntry == 0)
|
||||
return QString();
|
||||
|
||||
QString oldFamilyName = familyName(nameTableDirectoryEntry);
|
||||
|
||||
// Reserve size for name table header, five required name records and string
|
||||
const int requiredRecordCount = 5;
|
||||
quint16 nameIds[requiredRecordCount] = { 1, 2, 3, 4, 6 };
|
||||
|
||||
int sizeOfHeader = sizeof(NameTable) + sizeof(NameRecord) * requiredRecordCount;
|
||||
int newFamilyNameSize = newFamilyName.size() * sizeof(quint16);
|
||||
|
||||
const QString regularString = QString::fromLatin1("Regular");
|
||||
int regularStringSize = regularString.size() * sizeof(quint16);
|
||||
|
||||
// Align table size of table to 32 bits (pad with 0)
|
||||
int fullSize = ((sizeOfHeader + newFamilyNameSize + regularStringSize) & ~3) + 4;
|
||||
|
||||
QByteArray newNameTable(fullSize, char(0));
|
||||
|
||||
{
|
||||
NameTable *nameTable = reinterpret_cast<NameTable *>(newNameTable.data());
|
||||
nameTable->count = requiredRecordCount;
|
||||
nameTable->stringOffset = sizeOfHeader;
|
||||
|
||||
NameRecord *nameRecord = reinterpret_cast<NameRecord *>(nameTable + 1);
|
||||
for (int i=0; i<requiredRecordCount; ++i, nameRecord++) {
|
||||
nameRecord->nameID = nameIds[i];
|
||||
nameRecord->encodingID = 1;
|
||||
nameRecord->languageID = 0x0409;
|
||||
nameRecord->platformID = 3;
|
||||
nameRecord->length = newFamilyNameSize;
|
||||
|
||||
// Special case for sub-family
|
||||
if (nameIds[i] == 4) {
|
||||
nameRecord->offset = newFamilyNameSize;
|
||||
nameRecord->length = regularStringSize;
|
||||
}
|
||||
}
|
||||
|
||||
// nameRecord now points to string data
|
||||
BigEndian<quint16> *stringStorage = reinterpret_cast<BigEndian<quint16> *>(nameRecord);
|
||||
const quint16 *sourceString = newFamilyName.utf16();
|
||||
for (int i=0; i<newFamilyName.size(); ++i)
|
||||
stringStorage[i] = sourceString[i];
|
||||
stringStorage += newFamilyName.size();
|
||||
|
||||
sourceString = regularString.utf16();
|
||||
for (int i=0; i<regularString.size(); ++i)
|
||||
stringStorage[i] = sourceString[i];
|
||||
}
|
||||
|
||||
quint32 *p = reinterpret_cast<quint32 *>(newNameTable.data());
|
||||
quint32 *tableEnd = reinterpret_cast<quint32 *>(newNameTable.data() + fullSize);
|
||||
|
||||
quint32 checkSum = 0;
|
||||
while (p < tableEnd)
|
||||
checkSum += *(p++);
|
||||
|
||||
nameTableDirectoryEntry->checkSum = checkSum;
|
||||
nameTableDirectoryEntry->offset = m_fontData.size();
|
||||
nameTableDirectoryEntry->length = fullSize;
|
||||
|
||||
m_fontData.append(newNameTable);
|
||||
|
||||
return oldFamilyName;
|
||||
}
|
||||
|
||||
#if !defined(QT_NO_DIRECTWRITE)
|
||||
|
||||
class DirectWriteFontFileStream: public IDWriteFontFileStream
|
||||
{
|
||||
public:
|
||||
DirectWriteFontFileStream(const QByteArray &fontData)
|
||||
: m_fontData(fontData)
|
||||
, m_referenceCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
~DirectWriteFontFileStream()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **object);
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ReadFileFragment(const void **fragmentStart, UINT64 fileOffset,
|
||||
UINT64 fragmentSize, OUT void **fragmentContext);
|
||||
void STDMETHODCALLTYPE ReleaseFileFragment(void *fragmentContext);
|
||||
HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64 *fileSize);
|
||||
HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64 *lastWriteTime);
|
||||
|
||||
private:
|
||||
QByteArray m_fontData;
|
||||
ULONG m_referenceCount;
|
||||
};
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::QueryInterface(REFIID iid, void **object)
|
||||
{
|
||||
if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileStream)) {
|
||||
*object = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
} else {
|
||||
*object = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE DirectWriteFontFileStream::AddRef()
|
||||
{
|
||||
return InterlockedIncrement(&m_referenceCount);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE DirectWriteFontFileStream::Release()
|
||||
{
|
||||
ULONG newCount = InterlockedDecrement(&m_referenceCount);
|
||||
if (newCount == 0)
|
||||
delete this;
|
||||
return newCount;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::ReadFileFragment(
|
||||
const void **fragmentStart,
|
||||
UINT64 fileOffset,
|
||||
UINT64 fragmentSize,
|
||||
OUT void **fragmentContext)
|
||||
{
|
||||
*fragmentContext = NULL;
|
||||
if (fragmentSize + fileOffset <= m_fontData.size()) {
|
||||
*fragmentStart = m_fontData.data() + fileOffset;
|
||||
return S_OK;
|
||||
} else {
|
||||
*fragmentStart = NULL;
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
void STDMETHODCALLTYPE DirectWriteFontFileStream::ReleaseFileFragment(void *)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::GetFileSize(UINT64 *fileSize)
|
||||
{
|
||||
*fileSize = m_fontData.size();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileStream::GetLastWriteTime(UINT64 *lastWriteTime)
|
||||
{
|
||||
*lastWriteTime = 0;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
class DirectWriteFontFileLoader: public IDWriteFontFileLoader
|
||||
{
|
||||
public:
|
||||
DirectWriteFontFileLoader() : m_referenceCount(0) {}
|
||||
|
||||
~DirectWriteFontFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
inline void addKey(const void *key, const QByteArray &fontData)
|
||||
{
|
||||
Q_ASSERT(!m_fontDatas.contains(key));
|
||||
m_fontDatas.insert(key, fontData);
|
||||
}
|
||||
|
||||
inline void removeKey(const void *key)
|
||||
{
|
||||
m_fontDatas.remove(key);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **object);
|
||||
ULONG STDMETHODCALLTYPE AddRef();
|
||||
ULONG STDMETHODCALLTYPE Release();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateStreamFromKey(void const *fontFileReferenceKey,
|
||||
UINT32 fontFileReferenceKeySize,
|
||||
OUT IDWriteFontFileStream **fontFileStream);
|
||||
|
||||
private:
|
||||
ULONG m_referenceCount;
|
||||
QHash<const void *, QByteArray> m_fontDatas;
|
||||
};
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileLoader::QueryInterface(const IID &iid,
|
||||
void **object)
|
||||
{
|
||||
if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) {
|
||||
*object = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
} else {
|
||||
*object = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE DirectWriteFontFileLoader::AddRef()
|
||||
{
|
||||
return InterlockedIncrement(&m_referenceCount);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE DirectWriteFontFileLoader::Release()
|
||||
{
|
||||
ULONG newCount = InterlockedDecrement(&m_referenceCount);
|
||||
if (newCount == 0)
|
||||
delete this;
|
||||
return newCount;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DirectWriteFontFileLoader::CreateStreamFromKey(
|
||||
void const *fontFileReferenceKey,
|
||||
UINT32 fontFileReferenceKeySize,
|
||||
IDWriteFontFileStream **fontFileStream)
|
||||
{
|
||||
Q_UNUSED(fontFileReferenceKeySize);
|
||||
|
||||
if (fontFileReferenceKeySize != sizeof(const void *)) {
|
||||
qWarning("DirectWriteFontFileLoader::CreateStreamFromKey: Wrong key size");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
const void *key = *reinterpret_cast<void * const *>(fontFileReferenceKey);
|
||||
*fontFileStream = NULL;
|
||||
if (!m_fontDatas.contains(key))
|
||||
return E_FAIL;
|
||||
|
||||
QByteArray fontData = m_fontDatas.value(key);
|
||||
DirectWriteFontFileStream *stream = new DirectWriteFontFileStream(fontData);
|
||||
stream->AddRef();
|
||||
*fontFileStream = stream;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
class CustomFontFileLoader
|
||||
{
|
||||
public:
|
||||
CustomFontFileLoader() : m_directWriteFactory(0), m_directWriteFontFileLoader(0)
|
||||
{
|
||||
HRESULT hres = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown **>(&m_directWriteFactory));
|
||||
if (FAILED(hres)) {
|
||||
qErrnoWarning(hres, "CustomFontFileLoader::CustomFontFileLoader: "
|
||||
"DWriteCreateFactory failed.");
|
||||
} else {
|
||||
m_directWriteFontFileLoader = new DirectWriteFontFileLoader();
|
||||
m_directWriteFactory->RegisterFontFileLoader(m_directWriteFontFileLoader);
|
||||
}
|
||||
}
|
||||
|
||||
~CustomFontFileLoader()
|
||||
{
|
||||
if (m_directWriteFactory != 0 && m_directWriteFontFileLoader != 0)
|
||||
m_directWriteFactory->UnregisterFontFileLoader(m_directWriteFontFileLoader);
|
||||
|
||||
if (m_directWriteFactory != 0)
|
||||
m_directWriteFactory->Release();
|
||||
}
|
||||
|
||||
void addKey(const void *key, const QByteArray &fontData)
|
||||
{
|
||||
if (m_directWriteFontFileLoader != 0)
|
||||
m_directWriteFontFileLoader->addKey(key, fontData);
|
||||
}
|
||||
|
||||
void removeKey(const void *key)
|
||||
{
|
||||
if (m_directWriteFontFileLoader != 0)
|
||||
m_directWriteFontFileLoader->removeKey(key);
|
||||
}
|
||||
|
||||
IDWriteFontFileLoader *loader() const
|
||||
{
|
||||
return m_directWriteFontFileLoader;
|
||||
}
|
||||
|
||||
private:
|
||||
IDWriteFactory *m_directWriteFactory;
|
||||
DirectWriteFontFileLoader *m_directWriteFontFileLoader;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
|
||||
// From qfontdatabase_win.cpp
|
||||
extern QFontEngine *qt_load_font_engine_win(const QFontDef &request);
|
||||
// From qfontdatabase.cpp
|
||||
extern QFont::Weight weightFromInteger(int weight);
|
||||
|
||||
void QRawFontPrivate::platformCleanUp()
|
||||
{
|
||||
if (fontHandle != NULL) {
|
||||
if (ptrRemoveFontMemResourceEx == NULL) {
|
||||
QFunctionPointer func =
|
||||
QSystemLibrary::resolve(QLatin1String("gdi32"), "RemoveFontMemResourceEx");
|
||||
ptrRemoveFontMemResourceEx =
|
||||
reinterpret_cast<QRawFontPrivate::PtrRemoveFontMemResourceEx>(func);
|
||||
}
|
||||
|
||||
if (ptrRemoveFontMemResourceEx == NULL) {
|
||||
qWarning("QRawFont::platformCleanUp: Can't find RemoveFontMemResourceEx in gdi32");
|
||||
fontHandle = NULL;
|
||||
} else {
|
||||
ptrRemoveFontMemResourceEx(fontHandle);
|
||||
fontHandle = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QRawFontPrivate::platformLoadFromData(const QByteArray &_fontData,
|
||||
qreal pixelSize,
|
||||
QFont::HintingPreference hintingPreference)
|
||||
{
|
||||
QByteArray fontData(_fontData);
|
||||
EmbeddedFont font(fontData);
|
||||
|
||||
#if !defined(QT_NO_DIRECTWRITE)
|
||||
if (hintingPreference == QFont::PreferDefaultHinting
|
||||
|| hintingPreference == QFont::PreferFullHinting)
|
||||
#endif
|
||||
{
|
||||
GUID guid;
|
||||
CoCreateGuid(&guid);
|
||||
|
||||
QString uniqueFamilyName = QString::fromLatin1("f")
|
||||
+ QString::number(guid.Data1, 36) + QLatin1Char('-')
|
||||
+ QString::number(guid.Data2, 36) + QLatin1Char('-')
|
||||
+ QString::number(guid.Data3, 36) + QLatin1Char('-')
|
||||
+ QString::number(*reinterpret_cast<quint64 *>(guid.Data4), 36);
|
||||
|
||||
QString actualFontName = font.changeFamilyName(uniqueFamilyName);
|
||||
if (actualFontName.isEmpty()) {
|
||||
qWarning("QRawFont::platformLoadFromData: Can't change family name of font");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptrAddFontMemResourceEx == NULL || ptrRemoveFontMemResourceEx == NULL) {
|
||||
QFunctionPointer func =
|
||||
QSystemLibrary::resolve(QLatin1String("gdi32"), "RemoveFontMemResourceEx");
|
||||
ptrRemoveFontMemResourceEx =
|
||||
reinterpret_cast<QRawFontPrivate::PtrRemoveFontMemResourceEx>(func);
|
||||
|
||||
func = QSystemLibrary::resolve(QLatin1String("gdi32"), "AddFontMemResourceEx");
|
||||
ptrAddFontMemResourceEx =
|
||||
reinterpret_cast<QRawFontPrivate::PtrAddFontMemResourceEx>(func);
|
||||
}
|
||||
|
||||
Q_ASSERT(fontHandle == NULL);
|
||||
if (ptrAddFontMemResourceEx != NULL && ptrRemoveFontMemResourceEx != NULL) {
|
||||
DWORD count = 0;
|
||||
fontData = font.data();
|
||||
fontHandle = ptrAddFontMemResourceEx(fontData.data(), fontData.size(), 0, &count);
|
||||
|
||||
if (count == 0 && fontHandle != NULL) {
|
||||
ptrRemoveFontMemResourceEx(fontHandle);
|
||||
fontHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (fontHandle == NULL) {
|
||||
qWarning("QRawFont::platformLoadFromData: AddFontMemResourceEx failed");
|
||||
} else {
|
||||
QFontDef request;
|
||||
request.family = uniqueFamilyName;
|
||||
request.pixelSize = pixelSize;
|
||||
request.styleStrategy = QFont::NoFontMerging | QFont::PreferMatch;
|
||||
request.hintingPreference = hintingPreference;
|
||||
|
||||
fontEngine = qt_load_font_engine_win(request);
|
||||
if (request.family != fontEngine->fontDef.family) {
|
||||
qWarning("QRawFont::platformLoadFromData: Failed to load font. "
|
||||
"Got fallback instead: %s", qPrintable(fontEngine->fontDef.family));
|
||||
if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
|
||||
delete fontEngine;
|
||||
fontEngine = 0;
|
||||
} else {
|
||||
Q_ASSERT(fontEngine->cache_count == 0 && fontEngine->ref == 0);
|
||||
|
||||
// Override the generated font name
|
||||
static_cast<QFontEngineWin *>(fontEngine)->uniqueFamilyName = uniqueFamilyName;
|
||||
fontEngine->fontDef.family = actualFontName;
|
||||
fontEngine->ref.ref();
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !defined(QT_NO_DIRECTWRITE)
|
||||
else {
|
||||
CustomFontFileLoader fontFileLoader;
|
||||
fontFileLoader.addKey(this, fontData);
|
||||
|
||||
IDWriteFactory *factory = NULL;
|
||||
HRESULT hres = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory),
|
||||
reinterpret_cast<IUnknown **>(&factory));
|
||||
if (FAILED(hres)) {
|
||||
qErrnoWarning(hres, "QRawFont::platformLoadFromData: DWriteCreateFactory failed");
|
||||
return;
|
||||
}
|
||||
|
||||
IDWriteFontFile *fontFile = NULL;
|
||||
void *key = this;
|
||||
|
||||
hres = factory->CreateCustomFontFileReference(&key, sizeof(void *),
|
||||
fontFileLoader.loader(), &fontFile);
|
||||
if (FAILED(hres)) {
|
||||
qErrnoWarning(hres, "QRawFont::platformLoadFromData: "
|
||||
"CreateCustomFontFileReference failed");
|
||||
factory->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL isSupportedFontType;
|
||||
DWRITE_FONT_FILE_TYPE fontFileType;
|
||||
DWRITE_FONT_FACE_TYPE fontFaceType;
|
||||
UINT32 numberOfFaces;
|
||||
fontFile->Analyze(&isSupportedFontType, &fontFileType, &fontFaceType, &numberOfFaces);
|
||||
if (!isSupportedFontType) {
|
||||
fontFile->Release();
|
||||
factory->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
IDWriteFontFace *directWriteFontFace = NULL;
|
||||
hres = factory->CreateFontFace(fontFaceType, 1, &fontFile, 0, DWRITE_FONT_SIMULATIONS_NONE,
|
||||
&directWriteFontFace);
|
||||
if (FAILED(hres)) {
|
||||
qErrnoWarning(hres, "QRawFont::platformLoadFromData: CreateFontFace failed");
|
||||
fontFile->Release();
|
||||
factory->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
fontFile->Release();
|
||||
|
||||
fontEngine = new QFontEngineDirectWrite(factory, directWriteFontFace, pixelSize);
|
||||
|
||||
// Get font family from font data
|
||||
fontEngine->fontDef.family = font.familyName();
|
||||
fontEngine->ref.ref();
|
||||
|
||||
directWriteFontFace->Release();
|
||||
factory->Release();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get style and weight info
|
||||
if (fontEngine != 0) {
|
||||
TableDirectory *os2TableEntry = font.tableDirectoryEntry("OS/2");
|
||||
if (os2TableEntry != 0) {
|
||||
const OS2Table *os2Table =
|
||||
reinterpret_cast<const OS2Table *>(fontData.constData()
|
||||
+ os2TableEntry->offset);
|
||||
|
||||
bool italic = os2Table->selection & 1;
|
||||
bool oblique = os2Table->selection & 128;
|
||||
|
||||
if (italic)
|
||||
fontEngine->fontDef.style = QFont::StyleItalic;
|
||||
else if (oblique)
|
||||
fontEngine->fontDef.style = QFont::StyleOblique;
|
||||
else
|
||||
fontEngine->fontDef.style = QFont::StyleNormal;
|
||||
|
||||
fontEngine->fontDef.weight = weightFromInteger(os2Table->weightClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_RAWFONT
|
@ -1,149 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qatomic.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qbuffer.h"
|
||||
#include "qimage.h"
|
||||
#include "qpolygon.h"
|
||||
#include "qregion.h"
|
||||
#include "qt_windows.h"
|
||||
#include "qpainterpath.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 };
|
||||
|
||||
HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom)
|
||||
{
|
||||
const int tries = 10;
|
||||
for (int i = 0; i < tries; ++i) {
|
||||
HRGN region = 0;
|
||||
switch (type) {
|
||||
case QRegion::Rectangle:
|
||||
region = CreateRectRgn(left, top, right, bottom);
|
||||
break;
|
||||
case QRegion::Ellipse:
|
||||
#ifndef Q_OS_WINCE
|
||||
region = CreateEllipticRgn(left, top, right, bottom);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (region) {
|
||||
if (GetRegionData(region, 0, 0))
|
||||
return region;
|
||||
else
|
||||
DeleteObject(region);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QRegion qt_region_from_HRGN(HRGN rgn)
|
||||
{
|
||||
int numBytes = GetRegionData(rgn, 0, 0);
|
||||
if (numBytes == 0)
|
||||
return QRegion();
|
||||
|
||||
char *buf = new char[numBytes];
|
||||
if (buf == 0)
|
||||
return QRegion();
|
||||
|
||||
RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
|
||||
if (GetRegionData(rgn, numBytes, rd) == 0) {
|
||||
delete [] buf;
|
||||
return QRegion();
|
||||
}
|
||||
|
||||
QRegion region;
|
||||
RECT *r = reinterpret_cast<RECT*>(rd->Buffer);
|
||||
for (uint i = 0; i < rd->rdh.nCount; ++i) {
|
||||
QRect rect;
|
||||
rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1);
|
||||
++r;
|
||||
region |= rect;
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void qt_win_dispose_rgn(HRGN r)
|
||||
{
|
||||
if (r)
|
||||
DeleteObject(r);
|
||||
}
|
||||
|
||||
static void qt_add_rect(HRGN &winRegion, QRect r)
|
||||
{
|
||||
HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
|
||||
if (rgn) {
|
||||
HRGN dest = CreateRectRgn(0,0,0,0);
|
||||
int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
|
||||
if (result) {
|
||||
DeleteObject(winRegion);
|
||||
winRegion = dest;
|
||||
}
|
||||
DeleteObject(rgn);
|
||||
}
|
||||
}
|
||||
|
||||
void QRegion::ensureHandle() const
|
||||
{
|
||||
if (d->rgn)
|
||||
DeleteObject(d->rgn);
|
||||
d->rgn = CreateRectRgn(0,0,0,0);
|
||||
if (d->qt_rgn) {
|
||||
if (d->qt_rgn->numRects == 1) {
|
||||
QRect r = d->qt_rgn->extents;
|
||||
qt_add_rect(d->rgn, r);
|
||||
return;
|
||||
}
|
||||
for (int i = 0;i < d->qt_rgn->numRects;i++) {
|
||||
QRect r = d->qt_rgn->rects.at(i);
|
||||
qt_add_rect(d->rgn, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,205 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qsound.h"
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qapplication_p.h"
|
||||
#include <qfile.h>
|
||||
#include "qpointer.h"
|
||||
#include "qsound_p.h"
|
||||
|
||||
#include <qt_windows.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAuServerWindows : public QAuServer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QAuServerWindows(QObject* parent);
|
||||
~QAuServerWindows();
|
||||
|
||||
void playHelper(const QString &filename, int loop, QSound *snd);
|
||||
void play(const QString& filename, int loop);
|
||||
void play(QSound*);
|
||||
|
||||
void stop(QSound*);
|
||||
bool okay();
|
||||
|
||||
int decLoop(QSound *snd) { return QAuServer::decLoop(snd); }
|
||||
|
||||
HANDLE current;
|
||||
HANDLE mutex;
|
||||
HANDLE event;
|
||||
};
|
||||
|
||||
QAuServerWindows::QAuServerWindows(QObject* parent) :
|
||||
QAuServer(parent), current(0)
|
||||
{
|
||||
mutex = CreateMutex(0, 0, 0);
|
||||
event = CreateEvent(0, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
QAuServerWindows::~QAuServerWindows()
|
||||
{
|
||||
HANDLE mtx = mutex;
|
||||
WaitForSingleObject(mtx, INFINITE);
|
||||
mutex = 0;
|
||||
|
||||
ReleaseMutex(mtx);
|
||||
CloseHandle(mtx);
|
||||
CloseHandle(event);
|
||||
}
|
||||
|
||||
struct SoundInfo
|
||||
{
|
||||
SoundInfo(const QString &fn, int lp, QSound *snd, QAuServerWindows *srv)
|
||||
: sound(snd), server(srv), filename(fn), loops(lp)
|
||||
{
|
||||
}
|
||||
|
||||
QSound *sound;
|
||||
QAuServerWindows *server;
|
||||
QString filename;
|
||||
int loops;
|
||||
};
|
||||
|
||||
DWORD WINAPI SoundPlayProc(LPVOID param)
|
||||
{
|
||||
SoundInfo *info = (SoundInfo*)param;
|
||||
|
||||
// copy data before waking up GUI thread
|
||||
QAuServerWindows *server = info->server;
|
||||
QSound *sound = info->sound;
|
||||
int loops = info->loops;
|
||||
QString filename = info->filename;
|
||||
HANDLE mutex = server->mutex;
|
||||
HANDLE event = server->event;
|
||||
info = 0;
|
||||
|
||||
// server must not be destroyed until thread finishes
|
||||
// and all other sounds have to wait
|
||||
WaitForSingleObject(mutex, INFINITE);
|
||||
|
||||
if (loops <= 1) {
|
||||
server->current = 0;
|
||||
int flags = SND_FILENAME|SND_ASYNC;
|
||||
if (loops == -1)
|
||||
flags |= SND_LOOP;
|
||||
|
||||
PlaySound((wchar_t*)filename.utf16(), 0, flags);
|
||||
if (sound && loops == 1)
|
||||
server->decLoop(sound);
|
||||
|
||||
// GUI thread continues, but we are done as well.
|
||||
SetEvent(event);
|
||||
} else {
|
||||
// signal GUI thread to continue - sound might be reset!
|
||||
QPointer<QSound> guarded_sound = sound;
|
||||
SetEvent(event);
|
||||
|
||||
for (int l = 0; l < loops && server->current; ++l) {
|
||||
PlaySound((wchar_t*)filename.utf16(), 0, SND_FILENAME | SND_SYNC);
|
||||
|
||||
if (guarded_sound)
|
||||
server->decLoop(guarded_sound);
|
||||
}
|
||||
server->current = 0;
|
||||
}
|
||||
ReleaseMutex(mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QAuServerWindows::playHelper(const QString &filename, int loop, QSound *snd)
|
||||
{
|
||||
if (loop == 0)
|
||||
return;
|
||||
// busy?
|
||||
if (WaitForSingleObject(mutex, 0) == WAIT_TIMEOUT)
|
||||
return;
|
||||
ReleaseMutex(mutex);
|
||||
|
||||
DWORD threadid = 0;
|
||||
SoundInfo info(filename, loop, snd, this);
|
||||
current = CreateThread(0, 0, SoundPlayProc, &info, 0, &threadid);
|
||||
CloseHandle(current);
|
||||
|
||||
WaitForSingleObject(event, INFINITE);
|
||||
}
|
||||
|
||||
void QAuServerWindows::play(const QString& filename, int loop)
|
||||
{
|
||||
playHelper(filename, loop, 0);
|
||||
}
|
||||
|
||||
void QAuServerWindows::play(QSound* s)
|
||||
{
|
||||
playHelper(s->fileName(), s->loops(), s);
|
||||
}
|
||||
|
||||
void QAuServerWindows::stop(QSound*)
|
||||
{
|
||||
// stop unlooped sound
|
||||
if (!current)
|
||||
PlaySound(0, 0, 0);
|
||||
// stop after loop is done
|
||||
current = 0;
|
||||
}
|
||||
|
||||
bool QAuServerWindows::okay()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QAuServer* qt_new_audio_server()
|
||||
{
|
||||
return new QAuServerWindows(qApp);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qsound_win.moc"
|
||||
|
||||
#endif // QT_NO_SOUND
|
File diff suppressed because it is too large
Load Diff
@ -1,675 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef Q_WS_WINCE
|
||||
|
||||
#include "qguifunctions_wince.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp
|
||||
extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
//#define TABLET_DEBUG
|
||||
#define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE \
|
||||
| PK_ORIENTATION | PK_CURSOR | PK_Z)
|
||||
#define PACKETMODE 0
|
||||
|
||||
typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL);
|
||||
typedef BOOL (API *PtrWTClose)(HCTX);
|
||||
typedef UINT (API *PtrWTInfo)(UINT, UINT, LPVOID);
|
||||
typedef BOOL (API *PtrWTEnable)(HCTX, BOOL);
|
||||
typedef BOOL (API *PtrWTOverlap)(HCTX, BOOL);
|
||||
typedef int (API *PtrWTPacketsGet)(HCTX, int, LPVOID);
|
||||
typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT);
|
||||
typedef int (API *PtrWTQueueSizeGet)(HCTX);
|
||||
typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int);
|
||||
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
static void qt_tablet_init_wce();
|
||||
static void qt_tablet_cleanup_wce();
|
||||
|
||||
static void qt_tablet_init_wce() {
|
||||
static bool firstTime = true;
|
||||
if (!firstTime)
|
||||
return;
|
||||
firstTime = false;
|
||||
qt_tablet_widget = new QWidget(0);
|
||||
qt_tablet_widget->createWinId();
|
||||
qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget"));
|
||||
LOGCONTEXT lcMine;
|
||||
qAddPostRoutine(qt_tablet_cleanup_wce);
|
||||
struct tagAXIS tpOri[3];
|
||||
if (ptrWTInfo && ptrWTOpen && ptrWTQueueSizeGet && ptrWTQueueSizeSet) {
|
||||
// make sure we have WinTab
|
||||
if (!ptrWTInfo(0, 0, NULL)) {
|
||||
#ifdef TABLET_DEBUG
|
||||
qWarning("QWidget: Wintab services not available");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// some tablets don't support tilt, check if it is possible,
|
||||
qt_tablet_tilt_support = ptrWTInfo(WTI_DEVICES, DVC_ORIENTATION, &tpOri);
|
||||
if (qt_tablet_tilt_support) {
|
||||
// check for azimuth and altitude
|
||||
qt_tablet_tilt_support = tpOri[0].axResolution && tpOri[1].axResolution;
|
||||
}
|
||||
// build our context from the default context
|
||||
ptrWTInfo(WTI_DEFSYSCTX, 0, &lcMine);
|
||||
// Go for the raw coordinates, the tablet event will return good stuff
|
||||
lcMine.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;
|
||||
lcMine.lcPktData = PACKETDATA;
|
||||
lcMine.lcPktMode = PACKETMODE;
|
||||
lcMine.lcMoveMask = PACKETDATA;
|
||||
lcMine.lcOutOrgX = 0;
|
||||
lcMine.lcOutExtX = lcMine.lcInExtX;
|
||||
lcMine.lcOutOrgY = 0;
|
||||
lcMine.lcOutExtY = -lcMine.lcInExtY;
|
||||
qt_tablet_context = ptrWTOpen(qt_tablet_widget->winId(), &lcMine, true);
|
||||
#ifdef TABLET_DEBUG
|
||||
qDebug("Tablet is %p", qt_tablet_context);
|
||||
#endif
|
||||
if (!qt_tablet_context) {
|
||||
#ifdef TABLET_DEBUG
|
||||
qWarning("QWidget: Failed to open the tablet");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// Set the size of the Packet Queue to the correct size...
|
||||
int currSize = ptrWTQueueSizeGet(qt_tablet_context);
|
||||
if (!ptrWTQueueSizeSet(qt_tablet_context, QT_TABLET_NPACKETQSIZE)) {
|
||||
// Ideally one might want to use a smaller
|
||||
// multiple, but for now, since we managed to destroy
|
||||
// the existing Q with the previous call, set it back
|
||||
// to the other size, which should work. If not,
|
||||
// there will be trouble.
|
||||
if (!ptrWTQueueSizeSet(qt_tablet_context, currSize)) {
|
||||
Q_ASSERT_X(0, "Qt::Internal", "There is no packet queue for"
|
||||
" the tablet. The tablet will not work");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void qt_tablet_cleanup_wce() {
|
||||
if (ptrWTClose)
|
||||
ptrWTClose(qt_tablet_context);
|
||||
delete qt_tablet_widget;
|
||||
qt_tablet_widget = 0;
|
||||
}
|
||||
#endif // QT_NO_TABLETEVENT
|
||||
|
||||
|
||||
// The internal qWinRequestConfig, defined in qapplication_win.cpp, stores move,
|
||||
// resize and setGeometry requests for a widget that is already
|
||||
// processing a config event. The purpose is to avoid recursion.
|
||||
//
|
||||
void qWinRequestConfig(WId, int, int, int, int, int);
|
||||
|
||||
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) {
|
||||
Q_Q(QWidget);
|
||||
static int sw = -1, sh = -1;
|
||||
|
||||
Qt::WindowType type = q->windowType();
|
||||
Qt::WindowFlags flags = data.window_flags;
|
||||
|
||||
bool topLevel = (flags & Qt::Window);
|
||||
bool popup = (type == Qt::Popup);
|
||||
bool dialog = (type == Qt::Dialog
|
||||
|| type == Qt::Sheet
|
||||
|| (flags & Qt::MSWindowsFixedSizeDialogHint));
|
||||
bool desktop = (type == Qt::Desktop);
|
||||
bool tool = (type == Qt::Tool || type == Qt::Drawer);
|
||||
|
||||
HINSTANCE appinst = qWinAppInst();
|
||||
HWND parentw, destroyw = 0;
|
||||
WId id;
|
||||
|
||||
QString windowClassName = qt_reg_winclass(q);
|
||||
|
||||
if (!window) // always initialize
|
||||
initializeWindow = true;
|
||||
|
||||
if (popup)
|
||||
flags |= Qt::WindowStaysOnTopHint; // a popup stays on top
|
||||
|
||||
if (flags & (Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowContextHelpButtonHint)) {
|
||||
flags |= Qt::WindowSystemMenuHint;
|
||||
flags |= Qt::WindowTitleHint;
|
||||
flags &= ~Qt::FramelessWindowHint;
|
||||
}
|
||||
|
||||
if (sw < 0) { // get the (primary) screen size
|
||||
sw = GetSystemMetrics(SM_CXSCREEN);
|
||||
sh = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
|
||||
if (desktop) { // desktop widget
|
||||
popup = false; // force this flags off
|
||||
data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
||||
}
|
||||
|
||||
parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0;
|
||||
|
||||
QString title;
|
||||
int style = WS_CHILD;
|
||||
int exsty = WS_EX_NOPARENTNOTIFY;
|
||||
|
||||
if (topLevel) {
|
||||
if (!(flags & Qt::FramelessWindowHint) && !tool && !q->testAttribute(Qt::WA_DontShowOnScreen))
|
||||
style = (WS_OVERLAPPED) | WS_SYSMENU;
|
||||
else
|
||||
style = WS_POPUP;
|
||||
if ((type == Qt::ToolTip) || (type == Qt::SplashScreen)) {
|
||||
style = WS_POPUP;
|
||||
exsty |= WS_EX_NOANIMATION;
|
||||
} else {
|
||||
if (flags & Qt::WindowTitleHint)
|
||||
style |= WS_CAPTION;
|
||||
if (flags & Qt::WindowSystemMenuHint)
|
||||
style |= WS_SYSMENU;
|
||||
if (flags & Qt::WindowContextHelpButtonHint)
|
||||
exsty |= WS_EX_CONTEXTHELP;
|
||||
#ifndef Q_WS_WINCE_WM
|
||||
if (flags & Qt::WindowMinimizeButtonHint)
|
||||
style |= WS_MINIMIZEBOX;
|
||||
if (shouldShowMaximizeButton())
|
||||
style |= WS_MAXIMIZEBOX;
|
||||
#endif
|
||||
if (tool)
|
||||
exsty |= WS_EX_TOOLWINDOW;
|
||||
}
|
||||
}
|
||||
if (dialog) {
|
||||
style = WS_BORDER | WS_CAPTION;
|
||||
if (flags & Qt::WindowOkButtonHint)
|
||||
exsty |= WS_EX_CAPTIONOKBTN;
|
||||
if (flags & Qt::WindowCancelButtonHint || flags & Qt::WA_DeleteOnClose)
|
||||
style |= WS_SYSMENU;
|
||||
if (flags & Qt::WindowContextHelpButtonHint)
|
||||
exsty |= WS_EX_CONTEXTHELP;
|
||||
}
|
||||
if (popup) {
|
||||
style = WS_POPUP;
|
||||
exsty |= WS_EX_NOANIMATION;
|
||||
}
|
||||
|
||||
if (flags & Qt::WindowTitleHint) {
|
||||
title = q->isWindow() ? qAppName() : q->objectName();
|
||||
}
|
||||
|
||||
// The Qt::WA_WState_Created flag is checked by translateConfigEvent() in
|
||||
// qapplication_win.cpp. We switch it off temporarily to avoid move
|
||||
// and resize events during creationt
|
||||
q->setAttribute(Qt::WA_WState_Created, false);
|
||||
|
||||
if (window) { // override the old window
|
||||
if (destroyOldWindow)
|
||||
destroyw = data.winid;
|
||||
id = window;
|
||||
setWinId(window);
|
||||
LONG res = SetWindowLong(window, GWL_STYLE, style);
|
||||
if (!res)
|
||||
qErrnoWarning("QWidget::create: Failed to set window style");
|
||||
|
||||
res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc );
|
||||
|
||||
if (!res)
|
||||
qErrnoWarning("QWidget::create: Failed to set window procedure");
|
||||
} else if (desktop) { // desktop widget
|
||||
id = GetDesktopWindow();
|
||||
if (!id) { //Create a dummy desktop
|
||||
RECT r;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
|
||||
id = CreateWindow(reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
|
||||
reinterpret_cast<const wchar_t *>(title.utf16()), style,
|
||||
r.left, r.top, r.right - r.left, r.bottom - r.top,
|
||||
0, 0, appinst, 0);
|
||||
}
|
||||
setWinId(id);
|
||||
} else if (topLevel) { // create top-level widget
|
||||
const bool wasMoved = q->testAttribute(Qt::WA_Moved);
|
||||
|
||||
int x, y;
|
||||
if (qt_wince_is_mobile()) {
|
||||
x = wasMoved ? data.crect.left() : CW_USEDEFAULT;
|
||||
y = wasMoved ? data.crect.top() : CW_USEDEFAULT;
|
||||
} else {
|
||||
x = wasMoved ? data.crect.left() : 100;
|
||||
y = wasMoved ? data.crect.top() : 100;
|
||||
}
|
||||
|
||||
int w = CW_USEDEFAULT;
|
||||
int h = CW_USEDEFAULT;
|
||||
|
||||
// Adjust for framestrut when needed
|
||||
RECT rect = {0,0,0,0};
|
||||
if (AdjustWindowRectEx(&rect, style, FALSE, exsty)) {
|
||||
QTLWExtra *td = maybeTopData();
|
||||
if (wasMoved && (td && !td->posFromMove)) {
|
||||
x = data.crect.x() + rect.left;
|
||||
y = data.crect.y() + rect.top;
|
||||
}
|
||||
|
||||
if (q->testAttribute(Qt::WA_Resized)) {
|
||||
w = data.crect.width() + (rect.right - rect.left);
|
||||
h = data.crect.height() + (rect.bottom - rect.top);
|
||||
}
|
||||
}
|
||||
|
||||
id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
|
||||
reinterpret_cast<const wchar_t *>(title.utf16()), style,
|
||||
x, y, w, h,
|
||||
0, 0, appinst, 0);
|
||||
|
||||
if (!id)
|
||||
qErrnoWarning("QWidget::create: Failed to create window");
|
||||
setWinId(id);
|
||||
if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip))
|
||||
SetWindowPos(id, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
|
||||
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget
|
||||
id = CreateWindowEx(exsty, (wchar_t*)windowClassName.utf16(), (wchar_t*)title.utf16(), style,
|
||||
data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
|
||||
parentw, NULL, appinst, NULL);
|
||||
if (!id)
|
||||
qErrnoWarning("QWidget::create: Failed to create window");
|
||||
SetWindowPos(id, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
setWinId(id);
|
||||
}
|
||||
|
||||
if (desktop) {
|
||||
q->setAttribute(Qt::WA_WState_Visible);
|
||||
} else if (topLevel && !q->testAttribute(Qt::WA_DontShowOnScreen)) {
|
||||
RECT cr;
|
||||
GetClientRect(id, &cr);
|
||||
// one cannot trust cr.left and cr.top, use a correction POINT instead
|
||||
POINT pt;
|
||||
pt.x = 0;
|
||||
pt.y = 0;
|
||||
if (!q->testAttribute(Qt::WA_DontShowOnScreen) || q->testAttribute(Qt::WA_Moved))
|
||||
ClientToScreen(id, &pt);
|
||||
data.crect = QRect(QPoint(pt.x, pt.y),
|
||||
QPoint(pt.x + cr.right - 1, pt.y + cr.bottom - 1));
|
||||
|
||||
if (data.fstrut_dirty) {
|
||||
// be nice to activeqt
|
||||
updateFrameStrut();
|
||||
}
|
||||
}
|
||||
|
||||
q->setAttribute(Qt::WA_WState_Created); // accept move/resize events
|
||||
hd = 0; // no display context
|
||||
|
||||
if (window) { // got window from outside
|
||||
if (IsWindowVisible(window))
|
||||
q->setAttribute(Qt::WA_WState_Visible);
|
||||
else
|
||||
q->setAttribute(Qt::WA_WState_Visible, false);
|
||||
}
|
||||
|
||||
if (extra && !extra->mask.isEmpty())
|
||||
setMask_sys(extra->mask);
|
||||
|
||||
#if defined(QT_NON_COMMERCIAL)
|
||||
QT_NC_WIDGET_CREATE
|
||||
#endif
|
||||
|
||||
if (q->hasFocus() && q->testAttribute(Qt::WA_InputMethodEnabled))
|
||||
q->inputContext()->setFocusWidget(q);
|
||||
|
||||
if (destroyw) {
|
||||
DestroyWindow(destroyw);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
if (q != qt_tablet_widget && QWidgetPrivate::mapper)
|
||||
qt_tablet_init_wce();
|
||||
#endif // QT_NO_TABLETEVENT
|
||||
|
||||
if (q->testAttribute(Qt::WA_DropSiteRegistered))
|
||||
registerDropSite(true);
|
||||
|
||||
if (maybeTopData() && maybeTopData()->opacity != 255)
|
||||
q->setWindowOpacity(maybeTopData()->opacity/255.);
|
||||
|
||||
if (!topLevel && q->testAttribute(Qt::WA_NativeWindow) && q->testAttribute(Qt::WA_Mapped)) {
|
||||
Q_ASSERT(q->internalWinId());
|
||||
ShowWindow(q->internalWinId(), SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
\internal
|
||||
Platform-specific part of QWidget::show().
|
||||
*/
|
||||
void QWidgetPrivate::show_sys() {
|
||||
Q_Q(QWidget);
|
||||
#if defined(QT_NON_COMMERCIAL)
|
||||
QT_NC_SHOW_WINDOW
|
||||
#endif
|
||||
if (q->testAttribute(Qt::WA_OutsideWSRange))
|
||||
return;
|
||||
|
||||
q->setAttribute(Qt::WA_Mapped);
|
||||
|
||||
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
|
||||
|
||||
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
|
||||
invalidateBuffer(q->rect());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int sm = SW_SHOW;
|
||||
bool fakedMaximize = false;
|
||||
if (q->isWindow()) {
|
||||
#ifndef Q_WS_WINCE_WM
|
||||
if (q->isMinimized()) {
|
||||
sm = SW_SHOWMINIMIZED;
|
||||
} else if (q->isMaximized()) {
|
||||
sm = SW_SHOWMAXIMIZED;
|
||||
// Windows will not behave correctly when we try to maximize a window which does not
|
||||
// have minimize nor maximize buttons in the window frame. Windows would then ignore
|
||||
// non-available geometry, and rather maximize the widget to the full screen, minus the
|
||||
// window frame (caption). So, we do a trick here, by adding a maximize button before
|
||||
// maximizing the widget, and then remove the maximize button afterwards.
|
||||
Qt::WindowFlags &flags = data.window_flags;
|
||||
if (flags & Qt::WindowTitleHint &&
|
||||
!(flags & (Qt::WindowMinMaxButtonsHint | Qt::FramelessWindowHint))) {
|
||||
fakedMaximize = TRUE;
|
||||
int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
|
||||
SetWindowLong(q->internalWinId(), GWL_STYLE, style | WS_MAXIMIZEBOX);
|
||||
}
|
||||
} else
|
||||
#else
|
||||
// Imitate minimizing on Windows mobile by hiding the widget.
|
||||
if (q->isMinimized())
|
||||
sm = SW_HIDE;
|
||||
#endif
|
||||
if (q->isHidden()) {
|
||||
sm = SW_HIDE;
|
||||
}
|
||||
}
|
||||
if (q->testAttribute(Qt::WA_ShowWithoutActivating)
|
||||
|| (q->windowType() == Qt::Popup)
|
||||
|| (q->windowType() == Qt::ToolTip)
|
||||
|| (q->windowType() == Qt::Tool)) {
|
||||
sm = SW_SHOWNOACTIVATE;
|
||||
}
|
||||
|
||||
ShowWindow(q->internalWinId(), sm);
|
||||
|
||||
if (q->isMaximized() && q->isWindow())
|
||||
qt_wince_maximize(q);
|
||||
|
||||
#ifndef Q_WS_WINCE_WM
|
||||
if (!qt_wince_is_mobile() && q->isFullScreen()) {
|
||||
HWND handle = FindWindow(L"HHTaskBar", L"");
|
||||
if (handle) {
|
||||
ShowWindow(handle, SW_HIDE);
|
||||
EnableWindow(handle, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (fakedMaximize) {
|
||||
int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
|
||||
SetWindowLong(q->internalWinId(), GWL_STYLE, style & ~WS_MAXIMIZEBOX);
|
||||
SetWindowPos(q->internalWinId(), 0, 0, 0, 0, 0,
|
||||
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
|
||||
| SWP_FRAMECHANGED);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(fakedMaximize);
|
||||
#endif
|
||||
|
||||
if (q->isWindow() && sm == SW_SHOW)
|
||||
SetForegroundWindow(q->internalWinId());
|
||||
|
||||
invalidateBuffer(q->rect());
|
||||
}
|
||||
|
||||
void QWidget::setWindowState(Qt::WindowStates newstate)
|
||||
{
|
||||
Q_D(QWidget);
|
||||
Qt::WindowStates oldstate = windowState();
|
||||
if (oldstate == newstate)
|
||||
return;
|
||||
|
||||
int max = SW_SHOWNORMAL;
|
||||
int normal = SW_SHOWNOACTIVATE;
|
||||
|
||||
if ((oldstate & Qt::WindowMinimized) && !(newstate & Qt::WindowMinimized))
|
||||
newstate |= Qt::WindowActive;
|
||||
if (newstate & Qt::WindowActive)
|
||||
normal = SW_SHOWNORMAL;
|
||||
if (isWindow()) {
|
||||
createWinId();
|
||||
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
|
||||
// Ensure the initial size is valid, since we store it as normalGeometry below.
|
||||
if ((!testAttribute(Qt::WA_Resized) && !isVisible()))
|
||||
adjustSize();
|
||||
if (!d->topData()->normalGeometry.isValid()) {
|
||||
if (newstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen))
|
||||
d->topData()->normalGeometry = geometry();
|
||||
if (newstate & Qt::WindowMinimized && !(oldstate & Qt::WindowFullScreen))
|
||||
d->topData()->normalGeometry = geometry();
|
||||
}
|
||||
if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
|
||||
if (!(newstate & Qt::WindowMaximized)) {
|
||||
int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION;
|
||||
SetWindowLong(internalWinId(), GWL_STYLE, style);
|
||||
SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG);
|
||||
qt_wince_unmaximize(this);
|
||||
}
|
||||
if (isVisible() && newstate & Qt::WindowMaximized)
|
||||
qt_wince_maximize(this);
|
||||
if (isVisible() && !(newstate & Qt::WindowMinimized)) {
|
||||
ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
|
||||
if (!(newstate & Qt::WindowFullScreen)) {
|
||||
QRect r = d->topData()->normalGeometry;
|
||||
if (!(newstate & Qt::WindowMaximized) && r.width() >= 0) {
|
||||
if (pos() != r.topLeft() || size() !=r.size()) {
|
||||
d->topData()->normalGeometry = QRect(0,0,-1,-1);
|
||||
setGeometry(r);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d->updateFrameStrut();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
|
||||
if (newstate & Qt::WindowFullScreen) {
|
||||
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
|
||||
d->topData()->normalGeometry = geometry();
|
||||
d->topData()->savedFlags = (Qt::WindowFlags)GetWindowLong(internalWinId(), GWL_STYLE);
|
||||
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
|
||||
if (isVisible())
|
||||
style |= WS_VISIBLE;
|
||||
SetWindowLong(internalWinId(), GWL_STYLE, style);
|
||||
QRect r = qApp->desktop()->screenGeometry(this);
|
||||
UINT swpf = SWP_FRAMECHANGED;
|
||||
if (newstate & Qt::WindowActive)
|
||||
swpf |= SWP_NOACTIVATE;
|
||||
qt_wince_full_screen(internalWinId(), true, swpf);
|
||||
d->updateFrameStrut();
|
||||
} else {
|
||||
UINT style = d->topData()->savedFlags;
|
||||
if (isVisible())
|
||||
style |= WS_VISIBLE;
|
||||
SetWindowLong(internalWinId(), GWL_STYLE, style);
|
||||
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
|
||||
if (newstate & Qt::WindowActive)
|
||||
swpf |= SWP_NOACTIVATE;
|
||||
qt_wince_full_screen(internalWinId(), false, swpf);
|
||||
d->updateFrameStrut();
|
||||
|
||||
// preserve maximized state
|
||||
if (isVisible()) {
|
||||
ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
|
||||
if (newstate & Qt::WindowMaximized)
|
||||
qt_wince_maximize(this);
|
||||
}
|
||||
if (!(newstate & Qt::WindowMaximized)) {
|
||||
QRect r = d->topData()->normalGeometry;
|
||||
d->topData()->normalGeometry = QRect(0,0,-1,-1);
|
||||
if (r.isValid())
|
||||
setGeometry(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
|
||||
if (newstate & Qt::WindowMinimized)
|
||||
qt_wince_minimize(internalWinId());
|
||||
else if (newstate & Qt::WindowMaximized) {
|
||||
ShowWindow(internalWinId(), max);
|
||||
qt_wince_maximize(this);
|
||||
} else {
|
||||
ShowWindow(internalWinId(), normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
data->window_state = newstate;
|
||||
QWindowStateChangeEvent e(oldstate);
|
||||
QApplication::sendEvent(this, &e);
|
||||
}
|
||||
|
||||
void QWidgetPrivate::deleteSysExtra()
|
||||
{
|
||||
Q_Q(QWidget);
|
||||
if (!qt_wince_is_mobile() && q->isFullScreen()) {
|
||||
HWND handle = FindWindow(L"HHTaskBar", L"");
|
||||
if (handle) {
|
||||
ShowWindow(handle, SW_SHOWNORMAL);
|
||||
EnableWindow(handle, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QWidgetPrivate::setWindowOpacity_sys(qreal level) {
|
||||
Q_UNUSED(level);
|
||||
return;
|
||||
}
|
||||
|
||||
// The procedure does nothing, but is required for mousegrabbing to work
|
||||
LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||
Q_UNUSED(nCode);
|
||||
Q_UNUSED(wParam);
|
||||
Q_UNUSED(lParam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QWidget::grabMouse() {
|
||||
if (!qt_nograb()) {
|
||||
if (mouseGrb)
|
||||
mouseGrb->releaseMouse();
|
||||
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
|
||||
SetCapture(internalWinId());
|
||||
mouseGrb = this;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
void QWidget::grabMouse(const QCursor &cursor) {
|
||||
if (!qt_nograb()) {
|
||||
if (mouseGrb)
|
||||
mouseGrb->releaseMouse();
|
||||
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
|
||||
SetCapture(internalWinId());
|
||||
mouseGrbCur = new QCursor(cursor);
|
||||
SetCursor(mouseGrbCur->handle());
|
||||
mouseGrb = this;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void QWidget::releaseMouse() {
|
||||
if (!qt_nograb() && mouseGrb == this) {
|
||||
ReleaseCapture();
|
||||
if (journalRec) {
|
||||
journalRec = 0;
|
||||
}
|
||||
if (mouseGrbCur) {
|
||||
delete mouseGrbCur;
|
||||
mouseGrbCur = 0;
|
||||
}
|
||||
mouseGrb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QWidget::show()
|
||||
{
|
||||
Qt::WindowFlags flags = windowFlags() & 0xff;
|
||||
int threshold = qApp->autoMaximizeThreshold();
|
||||
if ((threshold < 0) || (windowState() & Qt::WindowFullScreen) || (windowState() & Qt::WindowMaximized)) {
|
||||
setVisible(true);
|
||||
return;
|
||||
}
|
||||
int height = sizeHint().height();
|
||||
int screenHeight = (qreal(threshold) / 100.0f * qApp->desktop()->screenGeometry(this).height());
|
||||
bool maximize = height > screenHeight;
|
||||
if (!maximize) {
|
||||
// If we do not maximize yet we check the widget and its child widgets whether they are
|
||||
//vertically expanding. If one of the widgets is expanding we maximize.
|
||||
QList<QWidget *> list = findChildren<QWidget *>();
|
||||
bool expandingChild = sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
|
||||
for (int i = 0; (i < list.size()) && !expandingChild; ++i) {
|
||||
expandingChild = list.at(i)->sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
|
||||
}
|
||||
maximize = expandingChild;
|
||||
}
|
||||
if ((minimumSizeHint().height() > qApp->desktop()->screenGeometry(this).height()) || (minimumSizeHint().width() > qApp->desktop()->screenGeometry(this).width()))
|
||||
maximize = false;
|
||||
|
||||
if ((flags == Qt::Window || flags == Qt::Dialog) && maximize) {
|
||||
setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
|
||||
| Qt::WindowMaximized);
|
||||
setVisible(true);
|
||||
}
|
||||
else {
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // Q_WS_WINCE
|
@ -1,111 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWININPUTCONTEXT_P_H
|
||||
#define QWININPUTCONTEXT_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qinputcontext.cpp. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtWidgets/qinputcontext.h"
|
||||
#include "QtCore/qt_windows.h"
|
||||
|
||||
#if !defined(IMR_RECONVERTSTRING)
|
||||
typedef struct tagRECONVERTSTRING {
|
||||
DWORD dwSize;
|
||||
DWORD dwVersion;
|
||||
DWORD dwStrLen;
|
||||
DWORD dwStrOffset;
|
||||
DWORD dwCompStrLen;
|
||||
DWORD dwCompStrOffset;
|
||||
DWORD dwTargetStrLen;
|
||||
DWORD dwTargetStrOffset;
|
||||
} RECONVERTSTRING, *PRECONVERTSTRING;
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWinInputContext : public QInputContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QWinInputContext(QObject* parent = 0);
|
||||
virtual ~QWinInputContext();
|
||||
|
||||
virtual QString identifierName() { return QLatin1String("win"); }
|
||||
virtual QString language();
|
||||
|
||||
virtual void reset();
|
||||
virtual void update();
|
||||
|
||||
virtual void mouseHandler(int x, QMouseEvent *event);
|
||||
virtual bool isComposing() const;
|
||||
|
||||
virtual void setFocusWidget(QWidget *w);
|
||||
|
||||
bool startComposition();
|
||||
bool endComposition();
|
||||
bool composition(LPARAM lparam);
|
||||
int reconvertString(RECONVERTSTRING *reconv);
|
||||
|
||||
static void TranslateMessage(const MSG *msg);
|
||||
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
static void updateImeStatus(QWidget *w, bool hasFocus);
|
||||
static void enablePopupChild(QWidget *w, bool e);
|
||||
static void enable(QWidget *w, bool e);
|
||||
|
||||
private:
|
||||
void init();
|
||||
bool recursionGuard;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWININPUTCONTEXT_P_H
|
@ -1,847 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwininputcontext_p.h"
|
||||
#include "qinputcontext_p.h"
|
||||
|
||||
#include "qfont.h"
|
||||
#include "qwidget.h"
|
||||
#include "qapplication.h"
|
||||
#include "qevent.h"
|
||||
#include "qtextformat.h"
|
||||
#include "qtextboundaryfinder.h"
|
||||
|
||||
//#define Q_IME_DEBUG
|
||||
|
||||
#ifdef Q_IME_DEBUG
|
||||
#include "qdebug.h"
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_WINCE)
|
||||
extern void qt_wince_show_SIP(bool show); // defined in qguifunctions_wince.cpp
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
|
||||
|
||||
|
||||
DEFINE_GUID(IID_IActiveIMMApp,
|
||||
0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
|
||||
|
||||
|
||||
|
||||
DEFINE_GUID(CLSID_CActiveIMM,
|
||||
0x4955DD33, 0xB159, 0x11d0, 0x8F, 0xCF, 0x0, 0xAA, 0x00, 0x6B, 0xCC, 0x59);
|
||||
|
||||
|
||||
|
||||
DEFINE_GUID(IID_IActiveIMMMessagePumpOwner,
|
||||
0xb5cf2cfa, 0x8aeb, 0x11d1, 0x93, 0x64, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
|
||||
|
||||
|
||||
|
||||
interface IEnumRegisterWordW;
|
||||
interface IEnumInputContext;
|
||||
|
||||
|
||||
bool qt_sendSpontaneousEvent(QObject*, QEvent*);
|
||||
|
||||
|
||||
#define IFMETHOD HRESULT STDMETHODCALLTYPE
|
||||
|
||||
interface IActiveIMMApp : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual IFMETHOD AssociateContext(HWND hWnd, HIMC hIME, HIMC __RPC_FAR *phPrev) = 0;
|
||||
virtual IFMETHOD dummy_ConfigureIMEA() = 0;
|
||||
virtual IFMETHOD ConfigureIMEW(HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDW __RPC_FAR *pData) = 0;
|
||||
virtual IFMETHOD CreateContext(HIMC __RPC_FAR *phIMC) = 0;
|
||||
virtual IFMETHOD DestroyContext(HIMC hIME) = 0;
|
||||
virtual IFMETHOD dummy_EnumRegisterWordA() = 0;
|
||||
virtual IFMETHOD EnumRegisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister, LPVOID pData,
|
||||
IEnumRegisterWordW __RPC_FAR *__RPC_FAR *pEnum) = 0;
|
||||
virtual IFMETHOD dummy_EscapeA() = 0;
|
||||
virtual IFMETHOD EscapeW(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT __RPC_FAR *plResult) = 0;
|
||||
virtual IFMETHOD dummy_GetCandidateListA() = 0;
|
||||
virtual IFMETHOD GetCandidateListW(HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST __RPC_FAR *pCandList,
|
||||
UINT __RPC_FAR *puCopied) = 0;
|
||||
virtual IFMETHOD dummy_GetCandidateListCountA() = 0;
|
||||
virtual IFMETHOD GetCandidateListCountW(HIMC hIMC, DWORD __RPC_FAR *pdwListSize, DWORD __RPC_FAR *pdwBufLen) = 0;
|
||||
virtual IFMETHOD GetCandidateWindow(HIMC hIMC, DWORD dwIndex, CANDIDATEFORM __RPC_FAR *pCandidate) = 0;
|
||||
virtual IFMETHOD dummy_GetCompositionFontA() = 0;
|
||||
virtual IFMETHOD GetCompositionFontW(HIMC hIMC, LOGFONTW __RPC_FAR *plf) = 0;
|
||||
virtual IFMETHOD dummy_GetCompositionStringA() = 0;
|
||||
virtual IFMETHOD GetCompositionStringW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG __RPC_FAR *plCopied, LPVOID pBuf) = 0;
|
||||
virtual IFMETHOD GetCompositionWindow(HIMC hIMC, COMPOSITIONFORM __RPC_FAR *pCompForm) = 0;
|
||||
virtual IFMETHOD GetContext(HWND hWnd, HIMC __RPC_FAR *phIMC) = 0;
|
||||
virtual IFMETHOD dummy_GetConversionListA() = 0;
|
||||
virtual IFMETHOD GetConversionListW(HKL hKL, HIMC hIMC, LPWSTR pSrc, UINT uBufLen, UINT uFlag,
|
||||
CANDIDATELIST __RPC_FAR *pDst, UINT __RPC_FAR *puCopied) = 0;
|
||||
virtual IFMETHOD GetConversionStatus(HIMC hIMC, DWORD __RPC_FAR *pfdwConversion, DWORD __RPC_FAR *pfdwSentence) = 0;
|
||||
virtual IFMETHOD GetDefaultIMEWnd(HWND hWnd, HWND __RPC_FAR *phDefWnd) = 0;
|
||||
virtual IFMETHOD dummy_GetDescriptionA() = 0;
|
||||
virtual IFMETHOD GetDescriptionW(HKL hKL, UINT uBufLen, LPWSTR szDescription, UINT __RPC_FAR *puCopied) = 0;
|
||||
virtual IFMETHOD dummy_GetGuideLineA() = 0;
|
||||
virtual IFMETHOD GetGuideLineW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf, DWORD __RPC_FAR *pdwResult) = 0;
|
||||
virtual IFMETHOD dummy_GetIMEFileNameA() = 0;
|
||||
virtual IFMETHOD GetIMEFileNameW(HKL hKL, UINT uBufLen, LPWSTR szFileName, UINT __RPC_FAR *puCopied) = 0;
|
||||
virtual IFMETHOD GetOpenStatus(HIMC hIMC) = 0;
|
||||
virtual IFMETHOD GetProperty(HKL hKL, DWORD fdwIndex, DWORD __RPC_FAR *pdwProperty) = 0;
|
||||
virtual IFMETHOD dummy_GetRegisterWordStyleA() = 0;
|
||||
virtual IFMETHOD GetRegisterWordStyleW(HKL hKL, UINT nItem, STYLEBUFW __RPC_FAR *pStyleBuf, UINT __RPC_FAR *puCopied) = 0;
|
||||
virtual IFMETHOD GetStatusWindowPos(HIMC hIMC, POINT __RPC_FAR *pptPos) = 0;
|
||||
virtual IFMETHOD GetVirtualKey(HWND hWnd, UINT __RPC_FAR *puVirtualKey) = 0;
|
||||
virtual IFMETHOD dummy_InstallIMEA() = 0;
|
||||
virtual IFMETHOD InstallIMEW(LPWSTR szIMEFileName, LPWSTR szLayoutText, HKL __RPC_FAR *phKL) = 0;
|
||||
virtual IFMETHOD IsIME(HKL hKL) = 0;
|
||||
virtual IFMETHOD dummy_IsUIMessageA() = 0;
|
||||
virtual IFMETHOD IsUIMessageW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam) = 0;
|
||||
virtual IFMETHOD NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) = 0;
|
||||
virtual IFMETHOD dummy_RegisterWordA() = 0;
|
||||
virtual IFMETHOD RegisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister) = 0;
|
||||
virtual IFMETHOD ReleaseContext(HWND hWnd, HIMC hIMC) = 0;
|
||||
virtual IFMETHOD SetCandidateWindow(HIMC hIMC, CANDIDATEFORM __RPC_FAR *pCandidate) = 0;
|
||||
virtual IFMETHOD SetCompositionFontA(HIMC hIMC, LOGFONTA __RPC_FAR *plf) = 0;
|
||||
virtual IFMETHOD SetCompositionFontW(HIMC hIMC, LOGFONTW __RPC_FAR *plf) = 0;
|
||||
virtual IFMETHOD dummy_SetCompositionStringA() = 0;
|
||||
virtual IFMETHOD SetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen,
|
||||
LPVOID pRead, DWORD dwReadLen) = 0;
|
||||
virtual IFMETHOD SetCompositionWindow(HIMC hIMC, COMPOSITIONFORM __RPC_FAR *pCompForm) = 0;
|
||||
virtual IFMETHOD SetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence) = 0;
|
||||
virtual IFMETHOD SetOpenStatus(HIMC hIMC, BOOL fOpen) = 0;
|
||||
virtual IFMETHOD SetStatusWindowPos(HIMC hIMC, POINT __RPC_FAR *pptPos) = 0;
|
||||
virtual IFMETHOD SimulateHotKey(HWND hWnd, DWORD dwHotKeyID) = 0;
|
||||
virtual IFMETHOD dummy_UnregisterWordA() = 0;
|
||||
virtual IFMETHOD UnregisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szUnregister) = 0;
|
||||
virtual IFMETHOD Activate(BOOL fRestoreLayout) = 0;
|
||||
virtual IFMETHOD Deactivate(void) = 0;
|
||||
virtual IFMETHOD OnDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT __RPC_FAR *plResult) = 0;
|
||||
virtual IFMETHOD FilterClientWindows(ATOM __RPC_FAR *aaClassList, UINT uSize) = 0;
|
||||
virtual IFMETHOD dummy_GetCodePageA() = 0;
|
||||
virtual IFMETHOD GetLangId(HKL hKL, LANGID __RPC_FAR *plid) = 0;
|
||||
virtual IFMETHOD AssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) = 0;
|
||||
virtual IFMETHOD DisableIME(DWORD idThread) = 0;
|
||||
virtual IFMETHOD dummy_GetImeMenuItemsA() = 0;
|
||||
virtual IFMETHOD GetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, /*IMEMENUITEMINFOW*/ void __RPC_FAR *pImeParentMenu,
|
||||
/*IMEMENUITEMINFOW*/ void __RPC_FAR *pImeMenu, DWORD dwSize, DWORD __RPC_FAR *pdwResult) = 0;
|
||||
virtual IFMETHOD EnumInputContext(DWORD idThread, IEnumInputContext __RPC_FAR *__RPC_FAR *ppEnum) = 0;
|
||||
};
|
||||
|
||||
interface IActiveIMMMessagePumpOwner : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual IFMETHOD Start(void) = 0;
|
||||
virtual IFMETHOD End(void) = 0;
|
||||
virtual IFMETHOD OnTranslateMessage(const MSG __RPC_FAR *pMsg) = 0;
|
||||
virtual IFMETHOD Pause(DWORD __RPC_FAR *pdwCookie) = 0;
|
||||
virtual IFMETHOD Resume(DWORD dwCookie) = 0;
|
||||
};
|
||||
|
||||
|
||||
static IActiveIMMApp *aimm = 0;
|
||||
static IActiveIMMMessagePumpOwner *aimmpump = 0;
|
||||
static QString *imeComposition = 0;
|
||||
static int imePosition = -1;
|
||||
bool qt_use_rtl_extensions = false;
|
||||
static bool haveCaret = false;
|
||||
|
||||
#ifndef LGRPID_INSTALLED
|
||||
#define LGRPID_INSTALLED 0x00000001 // installed language group ids
|
||||
#define LGRPID_SUPPORTED 0x00000002 // supported language group ids
|
||||
#endif
|
||||
|
||||
#ifndef LGRPID_ARABIC
|
||||
#define LGRPID_WESTERN_EUROPE 0x0001 // Western Europe & U.S.
|
||||
#define LGRPID_CENTRAL_EUROPE 0x0002 // Central Europe
|
||||
#define LGRPID_BALTIC 0x0003 // Baltic
|
||||
#define LGRPID_GREEK 0x0004 // Greek
|
||||
#define LGRPID_CYRILLIC 0x0005 // Cyrillic
|
||||
#define LGRPID_TURKISH 0x0006 // Turkish
|
||||
#define LGRPID_JAPANESE 0x0007 // Japanese
|
||||
#define LGRPID_KOREAN 0x0008 // Korean
|
||||
#define LGRPID_TRADITIONAL_CHINESE 0x0009 // Traditional Chinese
|
||||
#define LGRPID_SIMPLIFIED_CHINESE 0x000a // Simplified Chinese
|
||||
#define LGRPID_THAI 0x000b // Thai
|
||||
#define LGRPID_HEBREW 0x000c // Hebrew
|
||||
#define LGRPID_ARABIC 0x000d // Arabic
|
||||
#define LGRPID_VIETNAMESE 0x000e // Vietnamese
|
||||
#define LGRPID_INDIC 0x000f // Indic
|
||||
#define LGRPID_GEORGIAN 0x0010 // Georgian
|
||||
#define LGRPID_ARMENIAN 0x0011 // Armenian
|
||||
#endif
|
||||
|
||||
static DWORD WM_MSIME_MOUSE = 0;
|
||||
|
||||
QWinInputContext::QWinInputContext(QObject *parent)
|
||||
: QInputContext(parent), recursionGuard(false)
|
||||
{
|
||||
#ifndef Q_WS_WINCE
|
||||
QSysInfo::WinVersion ver = QSysInfo::windowsVersion();
|
||||
if (ver & QSysInfo::WV_NT_based && ver >= QSysInfo::WV_VISTA) {
|
||||
// Since the IsValidLanguageGroup/IsValidLocale functions always return true on
|
||||
// Vista, check the Keyboard Layouts for enabling RTL.
|
||||
UINT nLayouts = GetKeyboardLayoutList(0, 0);
|
||||
if (nLayouts) {
|
||||
HKL *lpList = new HKL[nLayouts];
|
||||
GetKeyboardLayoutList(nLayouts, lpList);
|
||||
for (int i = 0; i<(int)nLayouts; i++) {
|
||||
WORD plangid = PRIMARYLANGID((quintptr)lpList[i]);
|
||||
if (plangid == LANG_ARABIC
|
||||
|| plangid == LANG_HEBREW
|
||||
|| plangid == LANG_FARSI
|
||||
#ifdef LANG_SYRIAC
|
||||
|| plangid == LANG_SYRIAC
|
||||
#endif
|
||||
) {
|
||||
qt_use_rtl_extensions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete []lpList;
|
||||
}
|
||||
} else {
|
||||
// figure out whether a RTL language is installed
|
||||
qt_use_rtl_extensions = IsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED)
|
||||
|| IsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED)
|
||||
|| IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
|
||||
|| IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
|
||||
#ifdef LANG_SYRIAC
|
||||
|| IsValidLocale(MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
|
||||
#endif
|
||||
|| IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
|
||||
}
|
||||
#else
|
||||
qt_use_rtl_extensions = false;
|
||||
#endif
|
||||
|
||||
WM_MSIME_MOUSE = RegisterWindowMessage(L"MSIMEMouseOperation");
|
||||
}
|
||||
|
||||
QWinInputContext::~QWinInputContext()
|
||||
{
|
||||
// release active input method if we have one
|
||||
if (aimm) {
|
||||
aimmpump->End();
|
||||
aimmpump->Release();
|
||||
aimm->Deactivate();
|
||||
aimm->Release();
|
||||
aimm = 0;
|
||||
aimmpump = 0;
|
||||
}
|
||||
delete imeComposition;
|
||||
imeComposition = 0;
|
||||
}
|
||||
|
||||
static HWND getDefaultIMEWnd(HWND wnd)
|
||||
{
|
||||
HWND ime_wnd;
|
||||
if(aimm)
|
||||
aimm->GetDefaultIMEWnd(wnd, &ime_wnd);
|
||||
else
|
||||
ime_wnd = ImmGetDefaultIMEWnd(wnd);
|
||||
return ime_wnd;
|
||||
}
|
||||
|
||||
static HIMC getContext(HWND wnd)
|
||||
{
|
||||
HIMC imc;
|
||||
if (aimm)
|
||||
aimm->GetContext(wnd, &imc);
|
||||
else
|
||||
imc = ImmGetContext(wnd);
|
||||
|
||||
return imc;
|
||||
}
|
||||
|
||||
static void releaseContext(HWND wnd, HIMC imc)
|
||||
{
|
||||
if (aimm)
|
||||
aimm->ReleaseContext(wnd, imc);
|
||||
else
|
||||
ImmReleaseContext(wnd, imc);
|
||||
}
|
||||
|
||||
static void notifyIME(HIMC imc, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
|
||||
{
|
||||
if (!imc)
|
||||
return;
|
||||
if (aimm)
|
||||
aimm->NotifyIME(imc, dwAction, dwIndex, dwValue);
|
||||
else
|
||||
ImmNotifyIME(imc, dwAction, dwIndex, dwValue);
|
||||
}
|
||||
|
||||
static LONG getCompositionString(HIMC himc, DWORD dwIndex, LPVOID lpbuf, DWORD dBufLen)
|
||||
{
|
||||
LONG len = 0;
|
||||
if (aimm)
|
||||
aimm->GetCompositionStringW(himc, dwIndex, dBufLen, &len, lpbuf);
|
||||
else
|
||||
len = ImmGetCompositionString(himc, dwIndex, lpbuf, dBufLen);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int getCursorPosition(HIMC himc)
|
||||
{
|
||||
return getCompositionString(himc, GCS_CURSORPOS, 0, 0);
|
||||
}
|
||||
|
||||
static QString getString(HIMC himc, DWORD dwindex, int *selStart = 0, int *selLength = 0)
|
||||
{
|
||||
const int bufferSize = 256;
|
||||
wchar_t buffer[bufferSize];
|
||||
int len = getCompositionString(himc, dwindex, buffer, bufferSize * sizeof(wchar_t));
|
||||
|
||||
if (selStart) {
|
||||
char attrbuffer[bufferSize];
|
||||
int attrlen = getCompositionString(himc, GCS_COMPATTR, attrbuffer, bufferSize);
|
||||
*selStart = attrlen+1;
|
||||
*selLength = -1;
|
||||
for (int i = 0; i < attrlen; i++) {
|
||||
if (attrbuffer[i] & ATTR_TARGET_CONVERTED) {
|
||||
*selStart = qMin(*selStart, i);
|
||||
*selLength = qMax(*selLength, i);
|
||||
}
|
||||
}
|
||||
*selLength = qMax(0, *selLength - *selStart + 1);
|
||||
}
|
||||
|
||||
if (len <= 0)
|
||||
return QString();
|
||||
|
||||
return QString((QChar*)buffer, len / sizeof(QChar));
|
||||
}
|
||||
|
||||
void QWinInputContext::TranslateMessage(const MSG *msg)
|
||||
{
|
||||
if (!aimmpump || aimmpump->OnTranslateMessage(msg) != S_OK)
|
||||
::TranslateMessage(msg);
|
||||
}
|
||||
|
||||
LRESULT QWinInputContext::DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT retval;
|
||||
if (!aimm || aimm->OnDefWindowProc(hwnd, msg, wParam, lParam, &retval) != S_OK)
|
||||
{
|
||||
retval = ::DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void QWinInputContext::update()
|
||||
{
|
||||
QWidget *w = focusWidget();
|
||||
if(!w)
|
||||
return;
|
||||
|
||||
Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
|
||||
HIMC imc = getContext(w->effectiveWinId());
|
||||
|
||||
if (!imc)
|
||||
return;
|
||||
|
||||
QFont f = qvariant_cast<QFont>(w->inputMethodQuery(Qt::ImFont));
|
||||
HFONT hf;
|
||||
hf = f.handle();
|
||||
|
||||
LOGFONT lf;
|
||||
if (GetObject(hf, sizeof(lf), &lf)) {
|
||||
if (aimm)
|
||||
aimm->SetCompositionFontW(imc, &lf);
|
||||
else
|
||||
ImmSetCompositionFont(imc, &lf);
|
||||
}
|
||||
|
||||
QRect r = w->inputMethodQuery(Qt::ImMicroFocus).toRect();
|
||||
|
||||
// The ime window positions are based on the WinId with active focus.
|
||||
QWidget *imeWnd = QWidget::find(::GetFocus());
|
||||
if (imeWnd && !aimm) {
|
||||
QPoint pt (r.topLeft());
|
||||
pt = w->mapToGlobal(pt);
|
||||
pt = imeWnd->mapFromGlobal(pt);
|
||||
r.moveTo(pt);
|
||||
}
|
||||
|
||||
COMPOSITIONFORM cf;
|
||||
// ### need X-like inputStyle config settings
|
||||
cf.dwStyle = CFS_FORCE_POSITION;
|
||||
cf.ptCurrentPos.x = r.x();
|
||||
cf.ptCurrentPos.y = r.y();
|
||||
|
||||
CANDIDATEFORM candf;
|
||||
candf.dwIndex = 0;
|
||||
candf.dwStyle = CFS_EXCLUDE;
|
||||
candf.ptCurrentPos.x = r.x();
|
||||
candf.ptCurrentPos.y = r.y() + r.height();
|
||||
candf.rcArea.left = r.x();
|
||||
candf.rcArea.top = r.y();
|
||||
candf.rcArea.right = r.x() + r.width();
|
||||
candf.rcArea.bottom = r.y() + r.height();
|
||||
|
||||
if(haveCaret)
|
||||
SetCaretPos(r.x(), r.y());
|
||||
|
||||
if (aimm) {
|
||||
aimm->SetCompositionWindow(imc, &cf);
|
||||
aimm->SetCandidateWindow(imc, &candf);
|
||||
} else {
|
||||
ImmSetCompositionWindow(imc, &cf);
|
||||
ImmSetCandidateWindow(imc, &candf);
|
||||
}
|
||||
|
||||
releaseContext(w->effectiveWinId(), imc);
|
||||
}
|
||||
|
||||
|
||||
bool QWinInputContext::endComposition()
|
||||
{
|
||||
QWidget *fw = focusWidget();
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("endComposition! fw = %s", fw ? fw->className() : "(null)");
|
||||
#endif
|
||||
bool result = true;
|
||||
if(imePosition == -1 || recursionGuard)
|
||||
return result;
|
||||
|
||||
// Googles Pinyin Input Method likes to call endComposition again
|
||||
// when we call notifyIME with CPS_CANCEL, so protect ourselves
|
||||
// against that.
|
||||
recursionGuard = true;
|
||||
|
||||
if (fw) {
|
||||
Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created));
|
||||
HIMC imc = getContext(fw->effectiveWinId());
|
||||
notifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
|
||||
releaseContext(fw->effectiveWinId(), imc);
|
||||
if(haveCaret) {
|
||||
DestroyCaret();
|
||||
haveCaret = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fw)
|
||||
fw = QApplication::focusWidget();
|
||||
|
||||
if (fw) {
|
||||
QInputMethodEvent e;
|
||||
result = qt_sendSpontaneousEvent(fw, &e);
|
||||
}
|
||||
|
||||
if (imeComposition)
|
||||
imeComposition->clear();
|
||||
imePosition = -1;
|
||||
|
||||
recursionGuard = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void QWinInputContext::reset()
|
||||
{
|
||||
QWidget *fw = focusWidget();
|
||||
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("sending accept to focus widget %s", fw ? fw->className() : "(null)");
|
||||
#endif
|
||||
|
||||
if (fw && imePosition != -1) {
|
||||
QInputMethodEvent e;
|
||||
if (imeComposition)
|
||||
e.setCommitString(*imeComposition);
|
||||
imePosition = -1;
|
||||
qt_sendSpontaneousEvent(fw, &e);
|
||||
}
|
||||
|
||||
if (imeComposition)
|
||||
imeComposition->clear();
|
||||
imePosition = -1;
|
||||
|
||||
if (fw) {
|
||||
Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created));
|
||||
HIMC imc = getContext(fw->effectiveWinId());
|
||||
notifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
|
||||
releaseContext(fw->effectiveWinId(), imc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool QWinInputContext::startComposition()
|
||||
{
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("startComposition");
|
||||
#endif
|
||||
|
||||
if (!imeComposition)
|
||||
imeComposition = new QString();
|
||||
|
||||
QWidget *fw = focusWidget();
|
||||
if (fw) {
|
||||
Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created));
|
||||
imePosition = 0;
|
||||
haveCaret = CreateCaret(fw->effectiveWinId(), 0, 1, 1);
|
||||
HideCaret(fw->effectiveWinId());
|
||||
update();
|
||||
}
|
||||
return fw != 0;
|
||||
}
|
||||
|
||||
enum StandardFormat {
|
||||
PreeditFormat,
|
||||
SelectionFormat
|
||||
};
|
||||
|
||||
bool QWinInputContext::composition(LPARAM lParam)
|
||||
{
|
||||
#ifdef Q_IME_DEBUG
|
||||
QString str;
|
||||
if (lParam & GCS_RESULTSTR)
|
||||
str += "RESULTSTR ";
|
||||
if (lParam & GCS_COMPSTR)
|
||||
str += "COMPSTR ";
|
||||
if (lParam & GCS_COMPATTR)
|
||||
str += "COMPATTR ";
|
||||
if (lParam & GCS_CURSORPOS)
|
||||
str += "CURSORPOS ";
|
||||
if (lParam & GCS_COMPCLAUSE)
|
||||
str += "COMPCLAUSE ";
|
||||
if (lParam & CS_INSERTCHAR)
|
||||
str += "INSERTCHAR ";
|
||||
if (lParam & CS_NOMOVECARET)
|
||||
str += "NOMOVECARET ";
|
||||
qDebug("composition, lParam=(%x) %s imePosition=%d", lParam, str.latin1(), imePosition);
|
||||
#endif
|
||||
|
||||
bool result = true;
|
||||
|
||||
if(!lParam)
|
||||
// bogus event
|
||||
return true;
|
||||
|
||||
QWidget *fw = QApplication::focusWidget();
|
||||
if (fw) {
|
||||
Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created));
|
||||
HIMC imc = getContext(fw->effectiveWinId());
|
||||
QInputMethodEvent e;
|
||||
if (lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) {
|
||||
if (imePosition == -1)
|
||||
// need to send a start event
|
||||
startComposition();
|
||||
|
||||
// some intermediate composition result
|
||||
int selStart, selLength;
|
||||
*imeComposition = getString(imc, GCS_COMPSTR, &selStart, &selLength);
|
||||
imePosition = getCursorPosition(imc);
|
||||
if (lParam & CS_INSERTCHAR && lParam & CS_NOMOVECARET) {
|
||||
// make korean work correctly. Hope this is correct for all IMEs
|
||||
selStart = 0;
|
||||
selLength = imeComposition->length();
|
||||
}
|
||||
if(selLength == 0)
|
||||
selStart = 0;
|
||||
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
if (selStart > 0)
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, selStart,
|
||||
standardFormat(PreeditFormat));
|
||||
if (selLength)
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selStart, selLength,
|
||||
standardFormat(SelectionFormat));
|
||||
if (selStart + selLength < imeComposition->length())
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selStart + selLength,
|
||||
imeComposition->length() - selStart - selLength,
|
||||
standardFormat(PreeditFormat));
|
||||
if(imePosition >= 0)
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, imePosition, selLength ? 0 : 1, QVariant());
|
||||
|
||||
e = QInputMethodEvent(*imeComposition, attrs);
|
||||
}
|
||||
if (lParam & GCS_RESULTSTR) {
|
||||
if(imePosition == -1)
|
||||
startComposition();
|
||||
// a fixed result, return the converted string
|
||||
*imeComposition = getString(imc, GCS_RESULTSTR);
|
||||
imePosition = -1;
|
||||
e.setCommitString(*imeComposition);
|
||||
imeComposition->clear();
|
||||
}
|
||||
result = qt_sendSpontaneousEvent(fw, &e);
|
||||
update();
|
||||
releaseContext(fw->effectiveWinId(), imc);
|
||||
}
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("imecomposition: cursor pos at %d, str=%x", imePosition, str[0].unicode());
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static HIMC defaultContext = 0;
|
||||
|
||||
// checks whether widget is a popup
|
||||
inline bool isPopup(QWidget *w)
|
||||
{
|
||||
if (w && (w->windowFlags() & Qt::Popup) == Qt::Popup)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
// checks whether widget is in a popup
|
||||
inline bool isInPopup(QWidget *w)
|
||||
{
|
||||
if (w && (isPopup(w) || isPopup(w->window())))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the parent widget, which is a non popup toplevel
|
||||
// this is valid only if the widget is/in a popup
|
||||
inline QWidget *findParentforPopup(QWidget *w)
|
||||
{
|
||||
QWidget *e = QWidget::find(w->effectiveWinId());
|
||||
// check if this or its parent is a popup
|
||||
while (isInPopup(e)) {
|
||||
e = e->window()->parentWidget();
|
||||
if (!e)
|
||||
break;
|
||||
e = QWidget::find(e->effectiveWinId());
|
||||
}
|
||||
if (e)
|
||||
return e->window();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// enables or disables the ime
|
||||
inline void enableIme(QWidget *w, bool value)
|
||||
{
|
||||
if (value) {
|
||||
// enable ime
|
||||
if (defaultContext)
|
||||
ImmAssociateContext(w->effectiveWinId(), defaultContext);
|
||||
#ifdef Q_WS_WINCE
|
||||
if (qApp->autoSipEnabled())
|
||||
qt_wince_show_SIP(true);
|
||||
#endif
|
||||
} else {
|
||||
// disable ime
|
||||
HIMC oldimc = ImmAssociateContext(w->effectiveWinId(), 0);
|
||||
if (!defaultContext)
|
||||
defaultContext = oldimc;
|
||||
#ifdef Q_WS_WINCE
|
||||
if (qApp->autoSipEnabled())
|
||||
qt_wince_show_SIP(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QWinInputContext::updateImeStatus(QWidget *w, bool hasFocus)
|
||||
{
|
||||
if (!w)
|
||||
return;
|
||||
// It's always the proxy that carries the hints.
|
||||
QWidget *focusProxyWidget = w->focusProxy();
|
||||
if (!focusProxyWidget)
|
||||
focusProxyWidget = w;
|
||||
bool e = w->testAttribute(Qt::WA_InputMethodEnabled) && w->isEnabled()
|
||||
&& !(focusProxyWidget->inputMethodHints() & (Qt::ImhExclusiveInputMask | Qt::ImhHiddenText));
|
||||
bool hasIme = e && hasFocus;
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("%s HasFocus = %d hasIme = %d e = %d ", w->className(), hasFocus, hasIme, e);
|
||||
#endif
|
||||
if (hasFocus || e) {
|
||||
if (isInPopup(w))
|
||||
QWinInputContext::enablePopupChild(w, hasIme);
|
||||
else
|
||||
QWinInputContext::enable(w, hasIme);
|
||||
}
|
||||
}
|
||||
|
||||
void QWinInputContext::enablePopupChild(QWidget *w, bool e)
|
||||
{
|
||||
if (aimm) {
|
||||
enable(w, e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w || !isInPopup(w))
|
||||
return;
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("enablePopupChild: w=%s, enable = %s", w ? w->className() : "(null)" , e ? "true" : "false");
|
||||
#endif
|
||||
QWidget *parent = findParentforPopup(w);
|
||||
if (parent) {
|
||||
// update ime status of the normal toplevel parent of the popup
|
||||
enableIme(parent, e);
|
||||
}
|
||||
QWidget *toplevel = w->window();
|
||||
if (toplevel) {
|
||||
// update ime status of the toplevel popup
|
||||
enableIme(toplevel, e);
|
||||
}
|
||||
}
|
||||
|
||||
void QWinInputContext::enable(QWidget *w, bool e)
|
||||
{
|
||||
if(w) {
|
||||
#ifdef Q_IME_DEBUG
|
||||
qDebug("enable: w=%s, enable = %s", w ? w->className() : "(null)" , e ? "true" : "false");
|
||||
#endif
|
||||
if (!w->testAttribute(Qt::WA_WState_Created))
|
||||
return;
|
||||
if(aimm) {
|
||||
HIMC oldimc;
|
||||
if (!e) {
|
||||
aimm->AssociateContext(w->effectiveWinId(), 0, &oldimc);
|
||||
if (!defaultContext)
|
||||
defaultContext = oldimc;
|
||||
} else if (defaultContext) {
|
||||
aimm->AssociateContext(w->effectiveWinId(), defaultContext, &oldimc);
|
||||
}
|
||||
} else {
|
||||
// update ime status on the widget
|
||||
QWidget *p = QWidget::find(w->effectiveWinId());
|
||||
if (p)
|
||||
enableIme(p, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QWinInputContext::setFocusWidget(QWidget *w)
|
||||
{
|
||||
QWidget *oldFocus = focusWidget();
|
||||
if (oldFocus == w)
|
||||
return;
|
||||
if (w) {
|
||||
QWinInputContext::updateImeStatus(w, true);
|
||||
} else {
|
||||
if (oldFocus)
|
||||
QWinInputContext::updateImeStatus(oldFocus , false);
|
||||
}
|
||||
QInputContext::setFocusWidget(w);
|
||||
update();
|
||||
}
|
||||
|
||||
bool QWinInputContext::isComposing() const
|
||||
{
|
||||
return imeComposition && !imeComposition->isEmpty();
|
||||
}
|
||||
|
||||
void QWinInputContext::mouseHandler(int pos, QMouseEvent *e)
|
||||
{
|
||||
if(e->type() != QEvent::MouseButtonPress)
|
||||
return;
|
||||
|
||||
if (pos < 0 || pos > imeComposition->length())
|
||||
reset();
|
||||
|
||||
// Probably should pass the correct button, but it seems to work fine like this.
|
||||
DWORD button = MK_LBUTTON;
|
||||
|
||||
QWidget *fw = focusWidget();
|
||||
if (fw) {
|
||||
Q_ASSERT(fw->testAttribute(Qt::WA_WState_Created));
|
||||
HIMC himc = getContext(fw->effectiveWinId());
|
||||
HWND ime_wnd = getDefaultIMEWnd(fw->effectiveWinId());
|
||||
SendMessage(ime_wnd, WM_MSIME_MOUSE, MAKELONG(MAKEWORD(button, pos == 0 ? 2 : 1), pos), (LPARAM)himc);
|
||||
releaseContext(fw->effectiveWinId(), himc);
|
||||
}
|
||||
//qDebug("mouseHandler: got value %d pos=%d", ret,pos);
|
||||
}
|
||||
|
||||
QString QWinInputContext::language()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
int QWinInputContext::reconvertString(RECONVERTSTRING *reconv)
|
||||
{
|
||||
QWidget *w = focusWidget();
|
||||
if(!w)
|
||||
return -1;
|
||||
|
||||
Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
|
||||
QString surroundingText = qvariant_cast<QString>(w->inputMethodQuery(Qt::ImSurroundingText));
|
||||
int memSize = sizeof(RECONVERTSTRING)+(surroundingText.length()+1)*sizeof(ushort);
|
||||
// If memory is not allocated, return the required size.
|
||||
if (!reconv) {
|
||||
if (surroundingText.isEmpty())
|
||||
return -1;
|
||||
else
|
||||
return memSize;
|
||||
}
|
||||
int pos = qvariant_cast<int>(w->inputMethodQuery(Qt::ImCursorPosition));
|
||||
// find the word in the surrounding text.
|
||||
QTextBoundaryFinder bounds(QTextBoundaryFinder::Word, surroundingText);
|
||||
bounds.setPosition(pos);
|
||||
if (bounds.isAtBoundary()) {
|
||||
if (QTextBoundaryFinder::EndWord == bounds.boundaryReasons())
|
||||
bounds.toPreviousBoundary();
|
||||
} else {
|
||||
bounds.toPreviousBoundary();
|
||||
}
|
||||
int startPos = bounds.position();
|
||||
bounds.toNextBoundary();
|
||||
int endPos = bounds.position();
|
||||
// select the text, this will be overwritten by following ime events.
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, startPos, endPos-startPos, QVariant());
|
||||
QInputMethodEvent e(QString(), attrs);
|
||||
qt_sendSpontaneousEvent(w, &e);
|
||||
|
||||
reconv->dwSize = memSize;
|
||||
reconv->dwVersion = 0;
|
||||
|
||||
reconv->dwStrLen = surroundingText.length();
|
||||
reconv->dwStrOffset = sizeof(RECONVERTSTRING);
|
||||
reconv->dwCompStrLen = endPos-startPos;
|
||||
reconv->dwCompStrOffset = startPos*sizeof(ushort);
|
||||
reconv->dwTargetStrLen = reconv->dwCompStrLen;
|
||||
reconv->dwTargetStrOffset = reconv->dwCompStrOffset;
|
||||
memcpy((char*)(reconv+1), surroundingText.utf16(), surroundingText.length()*sizeof(ushort));
|
||||
return memSize;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,133 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "private/qwinnativepangesturerecognizer_win_p.h"
|
||||
|
||||
#include "qevent.h"
|
||||
#include "qgraphicsitem.h"
|
||||
#include "qgesture.h"
|
||||
|
||||
#include "private/qgesture_p.h"
|
||||
#include "private/qevent_p.h"
|
||||
#include "private/qapplication_p.h"
|
||||
#include "private/qwidget_p.h"
|
||||
|
||||
#ifndef QT_NO_GESTURES
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_NATIVE_GESTURES)
|
||||
|
||||
QWinNativePanGestureRecognizer::QWinNativePanGestureRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
QGesture *QWinNativePanGestureRecognizer::create(QObject *target)
|
||||
{
|
||||
if (!target)
|
||||
return new QPanGesture; // a special case
|
||||
if (!target->isWidgetType())
|
||||
return 0;
|
||||
if (qobject_cast<QGraphicsObject *>(target))
|
||||
return 0;
|
||||
|
||||
QWidget *q = static_cast<QWidget *>(target);
|
||||
QWidgetPrivate *d = q->d_func();
|
||||
d->nativeGesturePanEnabled = true;
|
||||
d->winSetupGestures();
|
||||
|
||||
return new QPanGesture;
|
||||
}
|
||||
|
||||
QGestureRecognizer::Result QWinNativePanGestureRecognizer::recognize(QGesture *state,
|
||||
QObject *,
|
||||
QEvent *event)
|
||||
{
|
||||
QPanGesture *q = static_cast<QPanGesture*>(state);
|
||||
QPanGesturePrivate *d = q->d_func();
|
||||
|
||||
QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
|
||||
if (event->type() == QEvent::NativeGesture) {
|
||||
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
|
||||
switch(ev->gestureType) {
|
||||
case QNativeGestureEvent::GestureBegin:
|
||||
break;
|
||||
case QNativeGestureEvent::Pan:
|
||||
result = QGestureRecognizer::TriggerGesture;
|
||||
event->accept();
|
||||
break;
|
||||
case QNativeGestureEvent::GestureEnd:
|
||||
if (q->state() == Qt::NoGesture)
|
||||
return QGestureRecognizer::Ignore; // some other gesture has ended
|
||||
result = QGestureRecognizer::FinishGesture;
|
||||
break;
|
||||
default:
|
||||
return QGestureRecognizer::Ignore;
|
||||
}
|
||||
if (q->state() == Qt::NoGesture) {
|
||||
d->lastOffset = d->offset = QPointF();
|
||||
d->startPosition = ev->position;
|
||||
} else {
|
||||
d->lastOffset = d->offset;
|
||||
d->offset = QPointF(ev->position.x() - d->startPosition.x(),
|
||||
ev->position.y() - d->startPosition.y());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void QWinNativePanGestureRecognizer::reset(QGesture *state)
|
||||
{
|
||||
QPanGesture *pan = static_cast<QPanGesture*>(state);
|
||||
QPanGesturePrivate *d = pan->d_func();
|
||||
|
||||
d->lastOffset = d->offset = QPointF();
|
||||
d->startPosition = QPoint();
|
||||
d->acceleration = 0;
|
||||
|
||||
QGestureRecognizer::reset(state);
|
||||
}
|
||||
|
||||
#endif // QT_NO_NATIVE_GESTURES
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_GESTURES
|
@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H
|
||||
#define QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QGestureRecognizer>
|
||||
|
||||
#ifndef QT_NO_GESTURES
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_NATIVE_GESTURES)
|
||||
|
||||
class QWinNativePanGestureRecognizer : public QGestureRecognizer
|
||||
{
|
||||
public:
|
||||
QWinNativePanGestureRecognizer();
|
||||
|
||||
QGesture *create(QObject *target);
|
||||
QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
|
||||
void reset(QGesture *state);
|
||||
};
|
||||
|
||||
#endif // QT_NO_NATIVE_GESTURES
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_GESTURES
|
||||
|
||||
#endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,670 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcolormap.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qdebug.h"
|
||||
#include "qdesktopwidget.h"
|
||||
#include "qvarlengtharray.h"
|
||||
|
||||
#include "qx11info_x11.h"
|
||||
#include <private/qt_x11_p.h>
|
||||
#include <limits.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QColormapPrivate
|
||||
{
|
||||
public:
|
||||
QColormapPrivate()
|
||||
: ref(1), mode(QColormap::Direct), depth(0),
|
||||
colormap(0), defaultColormap(true),
|
||||
visual(0), defaultVisual(true),
|
||||
r_max(0), g_max(0), b_max(0),
|
||||
r_shift(0), g_shift(0), b_shift(0)
|
||||
{}
|
||||
|
||||
QAtomicInt ref;
|
||||
|
||||
QColormap::Mode mode;
|
||||
int depth;
|
||||
|
||||
Colormap colormap;
|
||||
bool defaultColormap;
|
||||
|
||||
Visual *visual;
|
||||
bool defaultVisual;
|
||||
|
||||
int r_max;
|
||||
int g_max;
|
||||
int b_max;
|
||||
|
||||
uint r_shift;
|
||||
uint g_shift;
|
||||
uint b_shift;
|
||||
|
||||
QVector<QColor> colors;
|
||||
QVector<int> pixels;
|
||||
};
|
||||
|
||||
|
||||
static uint right_align(uint v)
|
||||
{
|
||||
while (!(v & 0x1))
|
||||
v >>= 1;
|
||||
return v;
|
||||
}
|
||||
|
||||
static int lowest_bit(uint v)
|
||||
{
|
||||
int i;
|
||||
uint b = 1u;
|
||||
for (i = 0; ((v & b) == 0u) && i < 32; ++i)
|
||||
b <<= 1u;
|
||||
return i == 32 ? -1 : i;
|
||||
}
|
||||
|
||||
static int cube_root(int v)
|
||||
{
|
||||
if (v == 1)
|
||||
return 1;
|
||||
// brute force algorithm
|
||||
int i = 1;
|
||||
for (;;) {
|
||||
const int b = i * i * i;
|
||||
if (b <= v) {
|
||||
++i;
|
||||
} else {
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static Visual *find_visual(Display *display,
|
||||
int screen,
|
||||
int visual_class,
|
||||
int visual_id,
|
||||
int *depth,
|
||||
bool *defaultVisual)
|
||||
{
|
||||
XVisualInfo *vi, rvi;
|
||||
int count;
|
||||
|
||||
uint mask = VisualScreenMask;
|
||||
rvi.screen = screen;
|
||||
|
||||
if (visual_class != -1) {
|
||||
rvi.c_class = visual_class;
|
||||
mask |= VisualClassMask;
|
||||
}
|
||||
if (visual_id != -1) {
|
||||
rvi.visualid = visual_id;
|
||||
mask |= VisualIDMask;
|
||||
}
|
||||
|
||||
Visual *visual = DefaultVisual(display, screen);
|
||||
*defaultVisual = true;
|
||||
*depth = DefaultDepth(display, screen);
|
||||
|
||||
vi = XGetVisualInfo(display, mask, &rvi, &count);
|
||||
if (vi) {
|
||||
int best = 0;
|
||||
for (int x = 0; x < count; ++x) {
|
||||
if (vi[x].depth > vi[best].depth)
|
||||
best = x;
|
||||
}
|
||||
if (best >= 0 && best <= count && vi[best].visualid != XVisualIDFromVisual(visual)) {
|
||||
visual = vi[best].visual;
|
||||
*defaultVisual = (visual == DefaultVisual(display, screen));
|
||||
*depth = vi[best].depth;
|
||||
}
|
||||
}
|
||||
if (vi)
|
||||
XFree((char *)vi);
|
||||
return visual;
|
||||
}
|
||||
|
||||
static void query_colormap(QColormapPrivate *d, int screen)
|
||||
{
|
||||
Display *display = QX11Info::display();
|
||||
|
||||
// query existing colormap
|
||||
int q_colors = (((1u << d->depth) > 256u) ? 256u : (1u << d->depth));
|
||||
XColor queried[256];
|
||||
memset(queried, 0, sizeof(queried));
|
||||
for (int x = 0; x < q_colors; ++x)
|
||||
queried[x].pixel = x;
|
||||
XQueryColors(display, d->colormap, queried, q_colors);
|
||||
|
||||
d->colors.resize(q_colors);
|
||||
for (int x = 0; x < q_colors; ++x) {
|
||||
if (queried[x].red == 0
|
||||
&& queried[x].green == 0
|
||||
&& queried[x].blue == 0
|
||||
&& queried[x].pixel != BlackPixel(display, screen)) {
|
||||
// unallocated color cell, skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
d->colors[x] = QColor::fromRgbF(queried[x].red / float(USHRT_MAX),
|
||||
queried[x].green / float(USHRT_MAX),
|
||||
queried[x].blue / float(USHRT_MAX));
|
||||
}
|
||||
|
||||
// for missing colors, find the closest color in the existing colormap
|
||||
Q_ASSERT(d->pixels.size());
|
||||
for (int x = 0; x < d->pixels.size(); ++x) {
|
||||
if (d->pixels.at(x) != -1)
|
||||
continue;
|
||||
|
||||
QRgb rgb;
|
||||
if (d->mode == QColormap::Indexed) {
|
||||
const int r = (x / (d->g_max * d->b_max)) % d->r_max;
|
||||
const int g = (x / d->b_max) % d->g_max;
|
||||
const int b = x % d->b_max;
|
||||
rgb = qRgb((r * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1),
|
||||
(g * 0xff + (d->g_max - 1) / 2) / (d->g_max - 1),
|
||||
(b * 0xff + (d->b_max - 1) / 2) / (d->b_max - 1));
|
||||
} else {
|
||||
rgb = qRgb(x, x, x);
|
||||
}
|
||||
|
||||
// find closest color
|
||||
int mindist = INT_MAX, best = -1;
|
||||
for (int y = 0; y < q_colors; ++y) {
|
||||
int r = qRed(rgb) - (queried[y].red >> 8);
|
||||
int g = qGreen(rgb) - (queried[y].green >> 8);
|
||||
int b = qBlue(rgb) - (queried[y].blue >> 8);
|
||||
int dist = (r * r) + (g * g) + (b * b);
|
||||
if (dist < mindist) {
|
||||
mindist = dist;
|
||||
best = y;
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT(best >= 0 && best < q_colors);
|
||||
if (d->visual->c_class & 1) {
|
||||
XColor xcolor;
|
||||
xcolor.red = queried[best].red;
|
||||
xcolor.green = queried[best].green;
|
||||
xcolor.blue = queried[best].blue;
|
||||
xcolor.pixel = queried[best].pixel;
|
||||
|
||||
if (XAllocColor(display, d->colormap, &xcolor)) {
|
||||
d->pixels[x] = xcolor.pixel;
|
||||
} else {
|
||||
// some weird stuff is going on...
|
||||
d->pixels[x] = (qGray(rgb) < 127
|
||||
? BlackPixel(display, screen)
|
||||
: WhitePixel(display, screen));
|
||||
}
|
||||
} else {
|
||||
d->pixels[x] = best;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init_gray(QColormapPrivate *d, int screen)
|
||||
{
|
||||
d->pixels.resize(d->r_max);
|
||||
|
||||
for (int g = 0; g < d->g_max; ++g) {
|
||||
const int gray = (g * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1);
|
||||
const QRgb rgb = qRgb(gray, gray, gray);
|
||||
|
||||
d->pixels[g] = -1;
|
||||
|
||||
if (d->visual->c_class & 1) {
|
||||
XColor xcolor;
|
||||
xcolor.red = qRed(rgb) * 0x101;
|
||||
xcolor.green = qGreen(rgb) * 0x101;
|
||||
xcolor.blue = qBlue(rgb) * 0x101;
|
||||
xcolor.pixel = 0ul;
|
||||
|
||||
if (XAllocColor(QX11Info::display(), d->colormap, &xcolor))
|
||||
d->pixels[g] = xcolor.pixel;
|
||||
}
|
||||
}
|
||||
|
||||
query_colormap(d, screen);
|
||||
}
|
||||
|
||||
static void init_indexed(QColormapPrivate *d, int screen)
|
||||
{
|
||||
d->pixels.resize(d->r_max * d->g_max * d->b_max);
|
||||
|
||||
// create color cube
|
||||
for (int x = 0, r = 0; r < d->r_max; ++r) {
|
||||
for (int g = 0; g < d->g_max; ++g) {
|
||||
for (int b = 0; b < d->b_max; ++b, ++x) {
|
||||
const QRgb rgb = qRgb((r * 0xff + (d->r_max - 1) / 2) / (d->r_max - 1),
|
||||
(g * 0xff + (d->g_max - 1) / 2) / (d->g_max - 1),
|
||||
(b * 0xff + (d->b_max - 1) / 2) / (d->b_max - 1));
|
||||
|
||||
d->pixels[x] = -1;
|
||||
|
||||
if (d->visual->c_class & 1) {
|
||||
XColor xcolor;
|
||||
xcolor.red = qRed(rgb) * 0x101;
|
||||
xcolor.green = qGreen(rgb) * 0x101;
|
||||
xcolor.blue = qBlue(rgb) * 0x101;
|
||||
xcolor.pixel = 0ul;
|
||||
|
||||
if (XAllocColor(QX11Info::display(), d->colormap, &xcolor))
|
||||
d->pixels[x] = xcolor.pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query_colormap(d, screen);
|
||||
}
|
||||
|
||||
static void init_direct(QColormapPrivate *d, bool ownColormap)
|
||||
{
|
||||
if (d->visual->c_class != DirectColor || !ownColormap)
|
||||
return;
|
||||
|
||||
// preallocate 768 on the stack, so that we don't have to malloc
|
||||
// for the common case (<= 24 bpp)
|
||||
QVarLengthArray<XColor, 768> colorTable(d->r_max + d->g_max + d->b_max);
|
||||
int i = 0;
|
||||
|
||||
for (int r = 0; r < d->r_max; ++r) {
|
||||
colorTable[i].red = r << 8 | r;
|
||||
colorTable[i].pixel = r << d->r_shift;
|
||||
colorTable[i].flags = DoRed;
|
||||
++i;
|
||||
}
|
||||
|
||||
for (int g = 0; g < d->g_max; ++g) {
|
||||
colorTable[i].green = g << 8 | g;
|
||||
colorTable[i].pixel = g << d->g_shift;
|
||||
colorTable[i].flags = DoGreen;
|
||||
++i;
|
||||
}
|
||||
|
||||
for (int b = 0; b < d->b_max; ++b) {
|
||||
colorTable[i].blue = (b << 8 | b);
|
||||
colorTable[i].pixel = b << d->b_shift;
|
||||
colorTable[i].flags = DoBlue;
|
||||
++i;
|
||||
}
|
||||
|
||||
XStoreColors(X11->display, d->colormap, colorTable.data(), colorTable.count());
|
||||
}
|
||||
|
||||
static QColormap **cmaps = 0;
|
||||
|
||||
void QColormap::initialize()
|
||||
{
|
||||
Display *display = QX11Info::display();
|
||||
const int screens = ScreenCount(display);
|
||||
|
||||
cmaps = new QColormap*[screens];
|
||||
|
||||
for (int i = 0; i < screens; ++i) {
|
||||
cmaps[i] = new QColormap;
|
||||
QColormapPrivate * const d = cmaps[i]->d;
|
||||
|
||||
bool use_stdcmap = false;
|
||||
int color_count = X11->color_count;
|
||||
|
||||
// defaults
|
||||
d->depth = DefaultDepth(display, i);
|
||||
d->colormap = DefaultColormap(display, i);
|
||||
d->defaultColormap = true;
|
||||
d->visual = DefaultVisual(display, i);
|
||||
d->defaultVisual = true;
|
||||
|
||||
Visual *argbVisual = 0;
|
||||
|
||||
if (X11->visual && i == DefaultScreen(display)) {
|
||||
// only use the outside colormap on the default screen
|
||||
d->visual = find_visual(display, i, X11->visual->c_class,
|
||||
XVisualIDFromVisual(X11->visual),
|
||||
&d->depth, &d->defaultVisual);
|
||||
} else if ((X11->visual_class != -1 && X11->visual_class >= 0 && X11->visual_class < 6)
|
||||
|| (X11->visual_id != -1)) {
|
||||
// look for a specific visual or type of visual
|
||||
d->visual = find_visual(display, i, X11->visual_class, X11->visual_id,
|
||||
&d->depth, &d->defaultVisual);
|
||||
} else if (QApplication::colorSpec() == QApplication::ManyColor) {
|
||||
// look for a TrueColor w/ a depth higher than 8bpp
|
||||
d->visual = find_visual(display, i, TrueColor, -1, &d->depth, &d->defaultVisual);
|
||||
if (d->depth <= 8) {
|
||||
d->visual = DefaultVisual(display, i);
|
||||
d->defaultVisual = true;
|
||||
color_count = 216;
|
||||
}
|
||||
} else if (!X11->custom_cmap) {
|
||||
XStandardColormap *stdcmap = 0;
|
||||
int ncmaps = 0;
|
||||
|
||||
#ifndef QT_NO_XRENDER
|
||||
if (X11->use_xrender) {
|
||||
int nvi;
|
||||
XVisualInfo templ;
|
||||
templ.screen = i;
|
||||
templ.depth = 32;
|
||||
templ.c_class = TrueColor;
|
||||
XVisualInfo *xvi = XGetVisualInfo(X11->display, VisualScreenMask |
|
||||
VisualDepthMask |
|
||||
VisualClassMask, &templ, &nvi);
|
||||
for (int idx = 0; idx < nvi; ++idx) {
|
||||
XRenderPictFormat *format = XRenderFindVisualFormat(X11->display,
|
||||
xvi[idx].visual);
|
||||
if (format->type == PictTypeDirect && format->direct.alphaMask) {
|
||||
argbVisual = xvi[idx].visual;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XFree(xvi);
|
||||
}
|
||||
#endif
|
||||
if (XGetRGBColormaps(display, RootWindow(display, i),
|
||||
&stdcmap, &ncmaps, XA_RGB_DEFAULT_MAP)) {
|
||||
if (stdcmap) {
|
||||
for (int c = 0; c < ncmaps; ++c) {
|
||||
if (!stdcmap[c].red_max ||
|
||||
!stdcmap[c].green_max ||
|
||||
!stdcmap[c].blue_max ||
|
||||
!stdcmap[c].red_mult ||
|
||||
!stdcmap[c].green_mult ||
|
||||
!stdcmap[c].blue_mult)
|
||||
continue; // invalid stdcmap
|
||||
|
||||
XVisualInfo proto;
|
||||
proto.visualid = stdcmap[c].visualid;
|
||||
proto.screen = i;
|
||||
|
||||
int nvisuals = 0;
|
||||
XVisualInfo *vi = XGetVisualInfo(display, VisualIDMask | VisualScreenMask,
|
||||
&proto, &nvisuals);
|
||||
if (vi) {
|
||||
if (nvisuals > 0) {
|
||||
use_stdcmap = true;
|
||||
|
||||
d->mode = ((vi[0].visual->c_class < StaticColor)
|
||||
? Gray
|
||||
: ((vi[0].visual->c_class < TrueColor)
|
||||
? Indexed
|
||||
: Direct));
|
||||
|
||||
d->depth = vi[0].depth;
|
||||
d->colormap = stdcmap[c].colormap;
|
||||
d->defaultColormap = true;
|
||||
d->visual = vi[0].visual;
|
||||
d->defaultVisual = (d->visual == DefaultVisual(display, i));
|
||||
|
||||
d->r_max = stdcmap[c].red_max + 1;
|
||||
d->g_max = stdcmap[c].green_max + 1;
|
||||
d->b_max = stdcmap[c].blue_max + 1;
|
||||
|
||||
if (d->mode == Direct) {
|
||||
// calculate offsets
|
||||
d->r_shift = lowest_bit(d->visual->red_mask);
|
||||
d->g_shift = lowest_bit(d->visual->green_mask);
|
||||
d->b_shift = lowest_bit(d->visual->blue_mask);
|
||||
} else {
|
||||
d->r_shift = 0;
|
||||
d->g_shift = 0;
|
||||
d->b_shift = 0;
|
||||
}
|
||||
}
|
||||
XFree(vi);
|
||||
}
|
||||
break;
|
||||
}
|
||||
XFree(stdcmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!use_stdcmap) {
|
||||
switch (d->visual->c_class) {
|
||||
case StaticGray:
|
||||
d->mode = Gray;
|
||||
|
||||
d->r_max = d->g_max = d->b_max = d->visual->map_entries;
|
||||
break;
|
||||
|
||||
case XGrayScale:
|
||||
d->mode = Gray;
|
||||
|
||||
// follow precedent set in libXmu...
|
||||
if (color_count != 0)
|
||||
d->r_max = d->g_max = d->b_max = color_count;
|
||||
else if (d->visual->map_entries > 65000)
|
||||
d->r_max = d->g_max = d->b_max = 4096;
|
||||
else if (d->visual->map_entries > 4000)
|
||||
d->r_max = d->g_max = d->b_max = 512;
|
||||
else if (d->visual->map_entries > 250)
|
||||
d->r_max = d->g_max = d->b_max = 12;
|
||||
else
|
||||
d->r_max = d->g_max = d->b_max = 4;
|
||||
break;
|
||||
|
||||
case StaticColor:
|
||||
d->mode = Indexed;
|
||||
|
||||
d->r_max = right_align(d->visual->red_mask) + 1;
|
||||
d->g_max = right_align(d->visual->green_mask) + 1;
|
||||
d->b_max = right_align(d->visual->blue_mask) + 1;
|
||||
break;
|
||||
|
||||
case PseudoColor:
|
||||
d->mode = Indexed;
|
||||
|
||||
// follow precedent set in libXmu...
|
||||
if (color_count != 0)
|
||||
d->r_max = d->g_max = d->b_max = cube_root(color_count);
|
||||
else if (d->visual->map_entries > 65000)
|
||||
d->r_max = d->g_max = d->b_max = 27;
|
||||
else if (d->visual->map_entries > 4000)
|
||||
d->r_max = d->g_max = d->b_max = 12;
|
||||
else if (d->visual->map_entries > 250)
|
||||
d->r_max = d->g_max = d->b_max = cube_root(d->visual->map_entries - 125);
|
||||
else
|
||||
d->r_max = d->g_max = d->b_max = cube_root(d->visual->map_entries);
|
||||
break;
|
||||
|
||||
case TrueColor:
|
||||
case DirectColor:
|
||||
d->mode = Direct;
|
||||
|
||||
d->r_max = right_align(d->visual->red_mask) + 1;
|
||||
d->g_max = right_align(d->visual->green_mask) + 1;
|
||||
d->b_max = right_align(d->visual->blue_mask) + 1;
|
||||
|
||||
d->r_shift = lowest_bit(d->visual->red_mask);
|
||||
d->g_shift = lowest_bit(d->visual->green_mask);
|
||||
d->b_shift = lowest_bit(d->visual->blue_mask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ownColormap = false;
|
||||
if (X11->colormap && i == DefaultScreen(display)) {
|
||||
// only use the outside colormap on the default screen
|
||||
d->colormap = X11->colormap;
|
||||
d->defaultColormap = (d->colormap == DefaultColormap(display, i));
|
||||
} else if ((!use_stdcmap
|
||||
&& (((d->visual->c_class & 1) && X11->custom_cmap)
|
||||
|| d->visual != DefaultVisual(display, i)))
|
||||
|| d->visual->c_class == DirectColor) {
|
||||
// allocate custom colormap (we always do this when using DirectColor visuals)
|
||||
d->colormap =
|
||||
XCreateColormap(display, RootWindow(display, i), d->visual,
|
||||
d->visual->c_class == DirectColor ? AllocAll : AllocNone);
|
||||
d->defaultColormap = false;
|
||||
ownColormap = true;
|
||||
}
|
||||
|
||||
switch (d->mode) {
|
||||
case Gray:
|
||||
init_gray(d, i);
|
||||
break;
|
||||
case Indexed:
|
||||
init_indexed(d, i);
|
||||
break;
|
||||
case Direct:
|
||||
init_direct(d, ownColormap);
|
||||
break;
|
||||
}
|
||||
|
||||
QX11InfoData *screen = X11->screens + i;
|
||||
screen->depth = d->depth;
|
||||
screen->visual = d->visual;
|
||||
screen->defaultVisual = d->defaultVisual;
|
||||
screen->colormap = d->colormap;
|
||||
screen->defaultColormap = d->defaultColormap;
|
||||
screen->cells = screen->visual->map_entries;
|
||||
|
||||
if (argbVisual) {
|
||||
X11->argbVisuals[i] = argbVisual;
|
||||
X11->argbColormaps[i] = XCreateColormap(display, RootWindow(display, i), argbVisual, AllocNone);
|
||||
}
|
||||
|
||||
// ###
|
||||
// We assume that 8bpp == pseudocolor, but this is not
|
||||
// always the case (according to the X server), so we need
|
||||
// to make sure that our internal data is setup in a way
|
||||
// that is compatible with our assumptions
|
||||
if (screen->visual->c_class == TrueColor && screen->depth == 8 && screen->cells == 8)
|
||||
screen->cells = 256;
|
||||
}
|
||||
}
|
||||
|
||||
void QColormap::cleanup()
|
||||
{
|
||||
Display *display = QX11Info::display();
|
||||
const int screens = ScreenCount(display);
|
||||
|
||||
for (int i = 0; i < screens; ++i)
|
||||
delete cmaps[i];
|
||||
|
||||
delete [] cmaps;
|
||||
cmaps = 0;
|
||||
}
|
||||
|
||||
|
||||
QColormap QColormap::instance(int screen)
|
||||
{
|
||||
if (screen == -1)
|
||||
screen = QX11Info::appScreen();
|
||||
return *cmaps[screen];
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Constructs a new colormap.
|
||||
*/
|
||||
QColormap::QColormap()
|
||||
: d(new QColormapPrivate)
|
||||
{}
|
||||
|
||||
QColormap::QColormap(const QColormap &colormap)
|
||||
:d (colormap.d)
|
||||
{ d->ref.ref(); }
|
||||
|
||||
QColormap::~QColormap()
|
||||
{
|
||||
if (!d->ref.deref()) {
|
||||
if (!d->defaultColormap)
|
||||
XFreeColormap(QX11Info::display(), d->colormap);
|
||||
delete d;
|
||||
}
|
||||
}
|
||||
|
||||
QColormap::Mode QColormap::mode() const
|
||||
{ return d->mode; }
|
||||
|
||||
int QColormap::depth() const
|
||||
{ return d->depth; }
|
||||
|
||||
int QColormap::size() const
|
||||
{
|
||||
return (d->mode == Gray
|
||||
? d->r_max
|
||||
: (d->mode == Indexed
|
||||
? d->r_max * d->g_max * d->b_max
|
||||
: -1));
|
||||
}
|
||||
|
||||
uint QColormap::pixel(const QColor &color) const
|
||||
{
|
||||
const QColor c = color.toRgb();
|
||||
const uint r = (c.ct.argb.red * d->r_max) >> 16;
|
||||
const uint g = (c.ct.argb.green * d->g_max) >> 16;
|
||||
const uint b = (c.ct.argb.blue * d->b_max) >> 16;
|
||||
if (d->mode != Direct) {
|
||||
if (d->mode == Gray)
|
||||
return d->pixels.at((r * 30 + g * 59 + b * 11) / 100);
|
||||
return d->pixels.at(r * d->g_max * d->b_max + g * d->b_max + b);
|
||||
}
|
||||
return (r << d->r_shift) + (g << d->g_shift) + (b << d->b_shift);
|
||||
}
|
||||
|
||||
const QColor QColormap::colorAt(uint pixel) const
|
||||
{
|
||||
if (d->mode != Direct) {
|
||||
Q_ASSERT(pixel <= (uint)d->colors.size());
|
||||
return d->colors.at(pixel);
|
||||
}
|
||||
|
||||
const int r = (((pixel & d->visual->red_mask) >> d->r_shift) << 8) / d->r_max;
|
||||
const int g = (((pixel & d->visual->green_mask) >> d->g_shift) << 8) / d->g_max;
|
||||
const int b = (((pixel & d->visual->blue_mask) >> d->b_shift) << 8) / d->b_max;
|
||||
return QColor(r, g, b);
|
||||
}
|
||||
|
||||
const QVector<QColor> QColormap::colormap() const
|
||||
{ return d->colors; }
|
||||
|
||||
QColormap &QColormap::operator=(const QColormap &colormap)
|
||||
{
|
||||
qAtomicAssign(d, colormap.d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,640 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qdatastream.h>
|
||||
#include <private/qcursor_p.h>
|
||||
#include <private/qt_x11_p.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qcursor.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include <qlibrary.h>
|
||||
|
||||
#ifndef QT_NO_XCURSOR
|
||||
# include <X11/Xcursor/Xcursor.h>
|
||||
#endif // QT_NO_XCURSOR
|
||||
|
||||
#ifndef QT_NO_XFIXES
|
||||
#ifndef Status
|
||||
#define Status int
|
||||
#endif
|
||||
# include <X11/extensions/Xfixes.h>
|
||||
#endif // QT_NO_XFIXES
|
||||
|
||||
#include "qx11info_x11.h"
|
||||
#include <private/qpixmap_x11_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to
|
||||
// use the ugly X11 cursors.
|
||||
|
||||
/*****************************************************************************
|
||||
Internal QCursorData class
|
||||
*****************************************************************************/
|
||||
|
||||
QCursorData::QCursorData(Qt::CursorShape s)
|
||||
: cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0), pm(0), pmm(0)
|
||||
{
|
||||
ref = 1;
|
||||
}
|
||||
|
||||
QCursorData::~QCursorData()
|
||||
{
|
||||
Display *dpy = X11 ? X11->display : (Display*)0;
|
||||
|
||||
// Add in checking for the display too as on HP-UX
|
||||
// we seem to get a core dump as the cursor data is
|
||||
// deleted again from main() on exit...
|
||||
if (hcurs && dpy)
|
||||
XFreeCursor(dpy, hcurs);
|
||||
if (pm && dpy)
|
||||
XFreePixmap(dpy, pm);
|
||||
if (pmm && dpy)
|
||||
XFreePixmap(dpy, pmm);
|
||||
delete bm;
|
||||
delete bmm;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
QCursor::QCursor(Qt::HANDLE cursor)
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
d = new QCursorData(Qt::CustomCursor);
|
||||
d->hcurs = cursor;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
|
||||
qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
|
||||
QCursorData *c = qt_cursorTable[0];
|
||||
c->ref.ref();
|
||||
return c;
|
||||
}
|
||||
QCursorData *d = new QCursorData;
|
||||
d->ref = 1;
|
||||
|
||||
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
|
||||
d->bm = new QBitmap(qt_toX11Pixmap(bitmap));
|
||||
d->bmm = new QBitmap(qt_toX11Pixmap(mask));
|
||||
|
||||
d->hcurs = 0;
|
||||
d->cshape = Qt::BitmapCursor;
|
||||
d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
|
||||
d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
|
||||
d->fg.red = 0x0000;
|
||||
d->fg.green = 0x0000;
|
||||
d->fg.blue = 0x0000;
|
||||
d->bg.red = 0xffff;
|
||||
d->bg.green = 0xffff;
|
||||
d->bg.blue = 0xffff;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
Qt::HANDLE QCursor::handle() const
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (!d->hcurs)
|
||||
d->update();
|
||||
return d->hcurs;
|
||||
}
|
||||
#endif
|
||||
|
||||
QPoint QCursor::pos()
|
||||
{
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = X11->display;
|
||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons))
|
||||
|
||||
return QPoint(root_x, root_y);
|
||||
}
|
||||
return QPoint();
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
#ifndef QT_NO_CURSOR
|
||||
int QCursor::x11Screen()
|
||||
{
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = X11->display;
|
||||
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QCursor::setPos(int x, int y)
|
||||
{
|
||||
QPoint current, target(x, y);
|
||||
|
||||
// this is copied from pos(), since we need the screen number for the correct
|
||||
// root window in the XWarpPointer call
|
||||
Window root;
|
||||
Window child;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
uint buttons;
|
||||
Display* dpy = X11->display;
|
||||
int screen;
|
||||
for (screen = 0; screen < ScreenCount(dpy); ++screen) {
|
||||
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
|
||||
&win_x, &win_y, &buttons)) {
|
||||
current = QPoint(root_x, root_y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (screen >= ScreenCount(dpy))
|
||||
return;
|
||||
|
||||
// Need to check, since some X servers generate null mouse move
|
||||
// events, causing looping in applications which call setPos() on
|
||||
// every mouse move event.
|
||||
//
|
||||
if (current == target)
|
||||
return;
|
||||
|
||||
XWarpPointer(X11->display, XNone, QX11Info::appRootWindow(screen), 0, 0, 0, 0, x, y);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Creates the cursor.
|
||||
*/
|
||||
|
||||
void QCursorData::update()
|
||||
{
|
||||
if (!QCursorData::initialized)
|
||||
QCursorData::initialize();
|
||||
if (hcurs)
|
||||
return;
|
||||
|
||||
Display *dpy = X11->display;
|
||||
Window rootwin = QX11Info::appRootWindow();
|
||||
|
||||
if (cshape == Qt::BitmapCursor) {
|
||||
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
|
||||
#ifndef QT_NO_XRENDER
|
||||
if (!pixmap.isNull() && X11->use_xrender) {
|
||||
pixmap = qt_toX11Pixmap(pixmap);
|
||||
hcurs = XRenderCreateCursor (X11->display, pixmap.x11PictureHandle(), hx, hy);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
hcurs = XCreatePixmapCursor(dpy, bm->handle(), bmm->handle(), &fg, &bg, hx, hy);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static const char *cursorNames[] = {
|
||||
"left_ptr",
|
||||
"up_arrow",
|
||||
"cross",
|
||||
"wait",
|
||||
"ibeam",
|
||||
"size_ver",
|
||||
"size_hor",
|
||||
"size_bdiag",
|
||||
"size_fdiag",
|
||||
"size_all",
|
||||
"blank",
|
||||
"split_v",
|
||||
"split_h",
|
||||
"pointing_hand",
|
||||
"forbidden",
|
||||
"whats_this",
|
||||
"left_ptr_watch",
|
||||
"openhand",
|
||||
"closedhand",
|
||||
"copy",
|
||||
"move",
|
||||
"link"
|
||||
};
|
||||
|
||||
#ifndef QT_NO_XCURSOR
|
||||
if (X11->ptrXcursorLibraryLoadCursor) {
|
||||
// special case for non-standard dnd-* cursors
|
||||
switch (cshape) {
|
||||
case Qt::DragCopyCursor:
|
||||
hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-copy");
|
||||
break;
|
||||
case Qt::DragMoveCursor:
|
||||
hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-move");
|
||||
break;
|
||||
case Qt::DragLinkCursor:
|
||||
hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-link");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!hcurs)
|
||||
hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]);
|
||||
}
|
||||
if (hcurs)
|
||||
return;
|
||||
#endif // QT_NO_XCURSOR
|
||||
|
||||
static const uchar cur_blank_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
// Non-standard X11 cursors are created from bitmaps
|
||||
|
||||
#ifndef QT_USE_APPROXIMATE_CURSORS
|
||||
static const uchar cur_ver_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
|
||||
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
|
||||
0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
|
||||
static const uchar mcur_ver_bits[] = {
|
||||
0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
|
||||
0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
|
||||
0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
|
||||
static const uchar cur_hor_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
|
||||
0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar mcur_hor_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
|
||||
0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
|
||||
0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
|
||||
static const uchar cur_bdiag_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
|
||||
0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
|
||||
0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar mcur_bdiag_bits[] = {
|
||||
0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
|
||||
0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
|
||||
0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar cur_fdiag_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
|
||||
0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
|
||||
0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar mcur_fdiag_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
|
||||
0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
|
||||
0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
|
||||
static const uchar *cursor_bits16[] = {
|
||||
cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
|
||||
cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
|
||||
0, 0, cur_blank_bits, cur_blank_bits };
|
||||
|
||||
static const uchar vsplit_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar vsplitm_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
||||
0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
||||
0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
||||
0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar hsplit_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
|
||||
0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
||||
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar hsplitm_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
|
||||
0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
|
||||
0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
|
||||
0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
||||
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar whatsthis_bits[] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
|
||||
0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
|
||||
0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
|
||||
0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
|
||||
0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
|
||||
0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
|
||||
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
||||
static const uchar whatsthism_bits[] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
|
||||
0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
|
||||
0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
|
||||
0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
|
||||
0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
|
||||
0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
|
||||
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
||||
static const uchar busy_bits[] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
|
||||
0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
|
||||
0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
|
||||
0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
|
||||
0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
|
||||
0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
|
||||
0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
static const uchar busym_bits[] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
|
||||
0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
|
||||
0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
|
||||
0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
|
||||
0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
|
||||
0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
|
||||
0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
static const uchar * const cursor_bits32[] = {
|
||||
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
|
||||
0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
|
||||
};
|
||||
|
||||
static const uchar forbidden_bits[] = {
|
||||
0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
|
||||
0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
|
||||
0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
|
||||
0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
|
||||
|
||||
static const uchar forbiddenm_bits[] = {
|
||||
0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
|
||||
0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
|
||||
0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
|
||||
0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
|
||||
|
||||
static const uchar openhand_bits[] = {
|
||||
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
|
||||
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
|
||||
0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
|
||||
static const uchar openhandm_bits[] = {
|
||||
0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
|
||||
0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
|
||||
0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
|
||||
static const uchar closedhand_bits[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
|
||||
0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
|
||||
0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
|
||||
static const uchar closedhandm_bits[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
|
||||
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
|
||||
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
|
||||
|
||||
static const uchar * const cursor_bits20[] = {
|
||||
forbidden_bits, forbiddenm_bits
|
||||
};
|
||||
|
||||
if ((cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor)
|
||||
|| cshape == Qt::BlankCursor) {
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
int i = (cshape - Qt::SizeVerCursor) * 2;
|
||||
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i]), 16, 16);
|
||||
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i + 1]), 16, 16);
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
||||
} else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
|
||||
|| cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) {
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
int i = (cshape - Qt::SplitVCursor) * 2;
|
||||
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i]), 32, 32);
|
||||
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i + 1]), 32, 32);
|
||||
int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
|
||||
|| cshape == Qt::BusyCursor) ? 0 : 16;
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, hs, hs);
|
||||
} else if (cshape == Qt::ForbiddenCursor) {
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
int i = (cshape - Qt::ForbiddenCursor) * 2;
|
||||
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i]), 20, 20);
|
||||
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i + 1]), 20, 20);
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10);
|
||||
} else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
bool open = cshape == Qt::OpenHandCursor;
|
||||
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhand_bits : closedhand_bits), 16, 16);
|
||||
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhandm_bits : closedhandm_bits), 16, 16);
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
||||
} else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor
|
||||
|| cshape == Qt::DragLinkCursor) {
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
QImage image = QApplicationPrivate::instance()->getPixmapCursor(cshape).toImage();
|
||||
pm = QX11PlatformPixmap::createBitmapFromImage(image);
|
||||
pmm = QX11PlatformPixmap::createBitmapFromImage(image.createAlphaMask().convertToFormat(QImage::Format_MonoLSB));
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
||||
}
|
||||
|
||||
if (hcurs)
|
||||
{
|
||||
#ifndef QT_NO_XFIXES
|
||||
if (X11->use_xfixes && X11->ptrXFixesSetCursorName)
|
||||
X11->ptrXFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
|
||||
#endif /* ! QT_NO_XFIXES */
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* ! QT_USE_APPROXIMATE_CURSORS */
|
||||
|
||||
uint sh;
|
||||
switch (cshape) { // map Q cursor to X cursor
|
||||
case Qt::ArrowCursor:
|
||||
sh = XC_left_ptr;
|
||||
break;
|
||||
case Qt::UpArrowCursor:
|
||||
sh = XC_center_ptr;
|
||||
break;
|
||||
case Qt::CrossCursor:
|
||||
sh = XC_crosshair;
|
||||
break;
|
||||
case Qt::WaitCursor:
|
||||
sh = XC_watch;
|
||||
break;
|
||||
case Qt::IBeamCursor:
|
||||
sh = XC_xterm;
|
||||
break;
|
||||
case Qt::SizeAllCursor:
|
||||
sh = XC_fleur;
|
||||
break;
|
||||
case Qt::PointingHandCursor:
|
||||
sh = XC_hand2;
|
||||
break;
|
||||
#ifdef QT_USE_APPROXIMATE_CURSORS
|
||||
case Qt::SizeBDiagCursor:
|
||||
sh = XC_top_right_corner;
|
||||
break;
|
||||
case Qt::SizeFDiagCursor:
|
||||
sh = XC_bottom_right_corner;
|
||||
break;
|
||||
case Qt::BlankCursor:
|
||||
XColor bg, fg;
|
||||
bg.red = 255 << 8;
|
||||
bg.green = 255 << 8;
|
||||
bg.blue = 255 << 8;
|
||||
fg.red = 0;
|
||||
fg.green = 0;
|
||||
fg.blue = 0;
|
||||
pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
|
||||
pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
|
||||
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
||||
return;
|
||||
break;
|
||||
case Qt::SizeVerCursor:
|
||||
case Qt::SplitVCursor:
|
||||
sh = XC_sb_v_double_arrow;
|
||||
break;
|
||||
case Qt::SizeHorCursor:
|
||||
case Qt::SplitHCursor:
|
||||
sh = XC_sb_h_double_arrow;
|
||||
break;
|
||||
case Qt::WhatsThisCursor:
|
||||
sh = XC_question_arrow;
|
||||
break;
|
||||
case Qt::ForbiddenCursor:
|
||||
sh = XC_circle;
|
||||
break;
|
||||
case Qt::BusyCursor:
|
||||
sh = XC_watch;
|
||||
break;
|
||||
case Qt::DragCopyCursor:
|
||||
sh = XC_tcross;
|
||||
break;
|
||||
case Qt::DragLinkCursor:
|
||||
sh = XC_center_ptr;
|
||||
break;
|
||||
case Qt::DragMoveCursor:
|
||||
sh = XC_top_left_arrow;
|
||||
break;
|
||||
#endif /* QT_USE_APPROXIMATE_CURSORS */
|
||||
default:
|
||||
qWarning("QCursor::update: Invalid cursor shape %d", cshape);
|
||||
return;
|
||||
}
|
||||
hcurs = XCreateFontCursor(dpy, sh);
|
||||
|
||||
#ifndef QT_NO_XFIXES
|
||||
if (X11->use_xfixes && X11->ptrXFixesSetCursorName)
|
||||
X11->ptrXFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
|
||||
#endif /* ! QT_NO_XFIXES */
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,406 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qdesktopwidget.h"
|
||||
#include "qlibrary.h"
|
||||
#include "qt_x11_p.h"
|
||||
#include "qvariant.h"
|
||||
#include "qwidget_p.h"
|
||||
#include "qx11info_x11.h"
|
||||
#include <limits.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// defined in qwidget_x11.cpp
|
||||
extern int qt_x11_create_desktop_on_screen;
|
||||
|
||||
|
||||
// function to update the workarea of the screen
|
||||
static bool qt_desktopwidget_workarea_dirty = true;
|
||||
void qt_desktopwidget_update_workarea()
|
||||
{
|
||||
qt_desktopwidget_workarea_dirty = true;
|
||||
}
|
||||
|
||||
|
||||
class QSingleDesktopWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
QSingleDesktopWidget();
|
||||
~QSingleDesktopWidget();
|
||||
};
|
||||
|
||||
QSingleDesktopWidget::QSingleDesktopWidget()
|
||||
: QWidget(0, Qt::Desktop)
|
||||
{
|
||||
}
|
||||
|
||||
QSingleDesktopWidget::~QSingleDesktopWidget()
|
||||
{
|
||||
const QObjectList &childList = children();
|
||||
for (int i = childList.size(); i > 0 ;) {
|
||||
--i;
|
||||
childList.at(i)->setParent(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QDesktopWidgetPrivate : public QWidgetPrivate
|
||||
{
|
||||
public:
|
||||
QDesktopWidgetPrivate();
|
||||
~QDesktopWidgetPrivate();
|
||||
|
||||
void init();
|
||||
|
||||
bool use_xinerama;
|
||||
int defaultScreen;
|
||||
int screenCount;
|
||||
|
||||
QWidget **screens;
|
||||
QRect *rects;
|
||||
QRect *workareas;
|
||||
};
|
||||
|
||||
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
|
||||
: use_xinerama(false), defaultScreen(0), screenCount(1),
|
||||
screens(0), rects(0), workareas(0)
|
||||
{
|
||||
}
|
||||
|
||||
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
|
||||
{
|
||||
if (screens) {
|
||||
for (int i = 0; i < screenCount; ++i) {
|
||||
if (i == defaultScreen) continue;
|
||||
delete screens[i];
|
||||
screens[i] = 0;
|
||||
}
|
||||
|
||||
free (screens);
|
||||
}
|
||||
|
||||
if (rects) delete [] rects;
|
||||
if (workareas) delete [] workareas;
|
||||
}
|
||||
|
||||
void QDesktopWidgetPrivate::init()
|
||||
{
|
||||
// get the screen count
|
||||
int newScreenCount = ScreenCount(X11->display);
|
||||
#ifndef QT_NO_XINERAMA
|
||||
|
||||
XineramaScreenInfo *xinerama_screeninfo = 0;
|
||||
|
||||
// we ignore the Xinerama extension when using the display is
|
||||
// using traditional multi-screen (with multiple root windows)
|
||||
if (newScreenCount == 1
|
||||
&& X11->ptrXineramaQueryExtension
|
||||
&& X11->ptrXineramaIsActive
|
||||
&& X11->ptrXineramaQueryScreens) {
|
||||
int unused;
|
||||
use_xinerama = (X11->ptrXineramaQueryExtension(X11->display, &unused, &unused)
|
||||
&& X11->ptrXineramaIsActive(X11->display));
|
||||
}
|
||||
|
||||
if (use_xinerama) {
|
||||
xinerama_screeninfo =
|
||||
X11->ptrXineramaQueryScreens(X11->display, &newScreenCount);
|
||||
}
|
||||
|
||||
if (xinerama_screeninfo) {
|
||||
defaultScreen = 0;
|
||||
} else
|
||||
#endif // QT_NO_XINERAMA
|
||||
{
|
||||
defaultScreen = DefaultScreen(X11->display);
|
||||
newScreenCount = ScreenCount(X11->display);
|
||||
use_xinerama = false;
|
||||
}
|
||||
|
||||
delete [] rects;
|
||||
rects = new QRect[newScreenCount];
|
||||
delete [] workareas;
|
||||
workareas = new QRect[newScreenCount];
|
||||
|
||||
// get the geometry of each screen
|
||||
int i, j, x, y, w, h;
|
||||
for (i = 0, j = 0; i < newScreenCount; i++, j++) {
|
||||
|
||||
#ifndef QT_NO_XINERAMA
|
||||
if (use_xinerama) {
|
||||
x = xinerama_screeninfo[i].x_org;
|
||||
y = xinerama_screeninfo[i].y_org;
|
||||
w = xinerama_screeninfo[i].width;
|
||||
h = xinerama_screeninfo[i].height;
|
||||
} else
|
||||
#endif // QT_NO_XINERAMA
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = WidthOfScreen(ScreenOfDisplay(X11->display, i));
|
||||
h = HeightOfScreen(ScreenOfDisplay(X11->display, i));
|
||||
}
|
||||
|
||||
rects[j].setRect(x, y, w, h);
|
||||
|
||||
if (use_xinerama && j > 0 && rects[j-1].intersects(rects[j])) {
|
||||
// merge a "cloned" screen with the previous, hiding all crtcs
|
||||
// that are currently showing a sub-rect of the previous screen
|
||||
if ((rects[j].width()*rects[j].height()) >
|
||||
(rects[j-1].width()*rects[j-1].height()))
|
||||
rects[j-1] = rects[j];
|
||||
j--;
|
||||
}
|
||||
|
||||
workareas[i] = QRect();
|
||||
}
|
||||
|
||||
if (screens) {
|
||||
// leaks QWidget* pointers on purpose, can't delete them as pointer escapes
|
||||
screens = q_check_ptr((QWidget**) realloc(screens, j * sizeof(QWidget*)));
|
||||
if (j > screenCount)
|
||||
memset(&screens[screenCount], 0, (j-screenCount) * sizeof(QWidget*));
|
||||
}
|
||||
|
||||
screenCount = j;
|
||||
|
||||
#ifndef QT_NO_XINERAMA
|
||||
if (use_xinerama && screenCount == 1)
|
||||
use_xinerama = false;
|
||||
|
||||
if (xinerama_screeninfo)
|
||||
XFree(xinerama_screeninfo);
|
||||
#endif // QT_NO_XINERAMA
|
||||
|
||||
}
|
||||
|
||||
// the QDesktopWidget itself will be created on the default screen
|
||||
// as qt_x11_create_desktop_on_screen defaults to -1
|
||||
QDesktopWidget::QDesktopWidget()
|
||||
: QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
|
||||
{
|
||||
Q_D(QDesktopWidget);
|
||||
d->init();
|
||||
}
|
||||
|
||||
QDesktopWidget::~QDesktopWidget()
|
||||
{
|
||||
}
|
||||
|
||||
bool QDesktopWidget::isVirtualDesktop() const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
return d->use_xinerama;
|
||||
}
|
||||
|
||||
int QDesktopWidget::primaryScreen() const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
return d->defaultScreen;
|
||||
}
|
||||
|
||||
int QDesktopWidget::numScreens() const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
return d->screenCount;
|
||||
}
|
||||
|
||||
QWidget *QDesktopWidget::screen(int screen)
|
||||
{
|
||||
Q_D(QDesktopWidget);
|
||||
if (d->use_xinerama)
|
||||
return this;
|
||||
|
||||
if (screen < 0 || screen >= d->screenCount)
|
||||
screen = d->defaultScreen;
|
||||
|
||||
if (! d->screens) {
|
||||
d->screens = (QWidget**) calloc( d->screenCount, sizeof(QWidget*));
|
||||
d->screens[d->defaultScreen] = this;
|
||||
}
|
||||
|
||||
if (! d->screens[screen] || // not created yet
|
||||
! (d->screens[screen]->windowType() == Qt::Desktop)) { // reparented away
|
||||
qt_x11_create_desktop_on_screen = screen;
|
||||
d->screens[screen] = new QSingleDesktopWidget;
|
||||
qt_x11_create_desktop_on_screen = -1;
|
||||
}
|
||||
|
||||
return d->screens[screen];
|
||||
}
|
||||
|
||||
const QRect QDesktopWidget::availableGeometry(int screen) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
if (qt_desktopwidget_workarea_dirty) {
|
||||
// the workareas are dirty, invalidate them
|
||||
for (int i = 0; i < d->screenCount; ++i)
|
||||
d->workareas[i] = QRect();
|
||||
qt_desktopwidget_workarea_dirty = false;
|
||||
}
|
||||
|
||||
if (screen < 0 || screen >= d->screenCount)
|
||||
screen = d->defaultScreen;
|
||||
|
||||
if (d->workareas[screen].isValid())
|
||||
return d->workareas[screen];
|
||||
|
||||
if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
|
||||
int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen;
|
||||
|
||||
Atom ret;
|
||||
int format, e;
|
||||
unsigned char *data = 0;
|
||||
unsigned long nitems, after;
|
||||
|
||||
e = XGetWindowProperty(X11->display,
|
||||
QX11Info::appRootWindow(x11Screen),
|
||||
ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
|
||||
&ret, &format, &nitems, &after, &data);
|
||||
|
||||
QRect workArea;
|
||||
if (e == Success && ret == XA_CARDINAL &&
|
||||
format == 32 && nitems == 4) {
|
||||
long *workarea = (long *) data;
|
||||
workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]);
|
||||
} else {
|
||||
workArea = screenGeometry(screen);
|
||||
}
|
||||
|
||||
if (isVirtualDesktop()) {
|
||||
// intersect the workarea (which spawns all Xinerama screens) with the rect for the
|
||||
// requested screen
|
||||
workArea &= screenGeometry(screen);
|
||||
}
|
||||
|
||||
d->workareas[screen] = workArea;
|
||||
|
||||
if (data)
|
||||
XFree(data);
|
||||
} else {
|
||||
d->workareas[screen] = screenGeometry(screen);
|
||||
}
|
||||
|
||||
return d->workareas[screen];
|
||||
}
|
||||
|
||||
const QRect QDesktopWidget::screenGeometry(int screen) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
if (screen < 0 || screen >= d->screenCount)
|
||||
screen = d->defaultScreen;
|
||||
|
||||
return d->rects[screen];
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QWidget *widget) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
if (!widget)
|
||||
return d->defaultScreen;
|
||||
|
||||
#ifndef QT_NO_XINERAMA
|
||||
if (d->use_xinerama) {
|
||||
// this is how we do it for xinerama
|
||||
QRect frame = widget->frameGeometry();
|
||||
if (!widget->isWindow())
|
||||
frame.moveTopLeft(widget->mapToGlobal(QPoint(0, 0)));
|
||||
|
||||
int maxSize = -1;
|
||||
int maxScreen = -1;
|
||||
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
QRect sect = d->rects[i].intersected(frame);
|
||||
int size = sect.width() * sect.height();
|
||||
if (size > maxSize && sect.width() > 0 && sect.height() > 0) {
|
||||
maxSize = size;
|
||||
maxScreen = i;
|
||||
}
|
||||
}
|
||||
return maxScreen;
|
||||
}
|
||||
#endif // QT_NO_XINERAMA
|
||||
|
||||
return widget->x11Info().screen();
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QPoint &point) const
|
||||
{
|
||||
Q_D(const QDesktopWidget);
|
||||
int closestScreen = -1;
|
||||
int shortestDistance = INT_MAX;
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
int thisDistance = d->pointToRect(point, d->rects[i]);
|
||||
if (thisDistance < shortestDistance) {
|
||||
shortestDistance = thisDistance;
|
||||
closestScreen = i;
|
||||
}
|
||||
}
|
||||
return closestScreen;
|
||||
}
|
||||
|
||||
void QDesktopWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_D(QDesktopWidget);
|
||||
int oldScreenCount = d->screenCount;
|
||||
QVector<QRect> oldRects(oldScreenCount);
|
||||
for (int i = 0; i < oldScreenCount; ++i) {
|
||||
oldRects[i] = d->rects[i];
|
||||
}
|
||||
|
||||
d->init();
|
||||
|
||||
for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
|
||||
if (oldRects.at(i) != d->rects[i])
|
||||
emit resized(i);
|
||||
}
|
||||
|
||||
if (oldScreenCount != d->screenCount) {
|
||||
emit screenCountChanged(d->screenCount);
|
||||
}
|
||||
|
||||
qt_desktopwidget_workarea_dirty = true;
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,191 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qeventdispatcher_x11_p.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qx11info_x11.h"
|
||||
|
||||
#include "qt_x11_p.h"
|
||||
#include <private/qeventdispatcher_unix_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QEventDispatcherX11Private : public QEventDispatcherUNIXPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QEventDispatcherX11)
|
||||
public:
|
||||
inline QEventDispatcherX11Private()
|
||||
: xfd(-1)
|
||||
{ }
|
||||
int xfd;
|
||||
QList<XEvent> queuedUserInputEvents;
|
||||
};
|
||||
|
||||
QEventDispatcherX11::QEventDispatcherX11(QObject *parent)
|
||||
: QEventDispatcherUNIX(*new QEventDispatcherX11Private, parent)
|
||||
{ }
|
||||
|
||||
QEventDispatcherX11::~QEventDispatcherX11()
|
||||
{ }
|
||||
|
||||
bool QEventDispatcherX11::processEvents(QEventLoop::ProcessEventsFlags flags)
|
||||
{
|
||||
Q_D(QEventDispatcherX11);
|
||||
|
||||
d->interrupt = false;
|
||||
QApplication::sendPostedEvents();
|
||||
|
||||
ulong marker = XNextRequest(X11->display);
|
||||
int nevents = 0;
|
||||
do {
|
||||
while (!d->interrupt) {
|
||||
XEvent event;
|
||||
if (!(flags & QEventLoop::ExcludeUserInputEvents)
|
||||
&& !d->queuedUserInputEvents.isEmpty()) {
|
||||
// process a pending user input event
|
||||
event = d->queuedUserInputEvents.takeFirst();
|
||||
} else if (XEventsQueued(X11->display, QueuedAlready)) {
|
||||
// process events from the X server
|
||||
XNextEvent(X11->display, &event);
|
||||
|
||||
if (flags & QEventLoop::ExcludeUserInputEvents) {
|
||||
// queue user input events
|
||||
switch (event.type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
case XKeyPress:
|
||||
case XKeyRelease:
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
d->queuedUserInputEvents.append(event);
|
||||
continue;
|
||||
|
||||
case ClientMessage:
|
||||
// only keep the wm_take_focus and
|
||||
// _qt_scrolldone protocols, queue all other
|
||||
// client messages
|
||||
if (event.xclient.format == 32) {
|
||||
if (event.xclient.message_type == ATOM(WM_PROTOCOLS) &&
|
||||
(Atom) event.xclient.data.l[0] == ATOM(WM_TAKE_FOCUS)) {
|
||||
break;
|
||||
} else if (event.xclient.message_type == ATOM(_QT_SCROLL_DONE)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
d->queuedUserInputEvents.append(event);
|
||||
continue;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no event to process
|
||||
break;
|
||||
}
|
||||
|
||||
// send through event filter
|
||||
if (filterEvent(&event))
|
||||
continue;
|
||||
|
||||
nevents++;
|
||||
if (qApp->x11ProcessEvent(&event) == 1)
|
||||
return true;
|
||||
|
||||
if (event.xany.serial >= marker) {
|
||||
if (XEventsQueued(X11->display, QueuedAfterFlush))
|
||||
flags &= ~QEventLoop::WaitForMoreEvents;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} while (!d->interrupt && XEventsQueued(X11->display, QueuedAfterFlush));
|
||||
|
||||
out:
|
||||
if (!d->interrupt) {
|
||||
const uint exclude_all =
|
||||
QEventLoop::ExcludeSocketNotifiers | QEventLoop::X11ExcludeTimers | QEventLoop::WaitForMoreEvents;
|
||||
if (nevents > 0 && ((uint)flags & exclude_all) == exclude_all) {
|
||||
QApplication::sendPostedEvents();
|
||||
return nevents > 0;
|
||||
}
|
||||
// return true if we handled events, false otherwise
|
||||
return QEventDispatcherUNIX::processEvents(flags) || (nevents > 0);
|
||||
}
|
||||
return nevents > 0;
|
||||
}
|
||||
|
||||
bool QEventDispatcherX11::hasPendingEvents()
|
||||
{
|
||||
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
|
||||
return (qGlobalPostedEventsCount() || XPending(X11->display));
|
||||
}
|
||||
|
||||
void QEventDispatcherX11::flush()
|
||||
{
|
||||
XFlush(X11->display);
|
||||
}
|
||||
|
||||
void QEventDispatcherX11::startingUp()
|
||||
{
|
||||
Q_D(QEventDispatcherX11);
|
||||
d->xfd = XConnectionNumber(X11->display);
|
||||
}
|
||||
|
||||
void QEventDispatcherX11::closingDown()
|
||||
{
|
||||
Q_D(QEventDispatcherX11);
|
||||
d->xfd = -1;
|
||||
}
|
||||
|
||||
int QEventDispatcherX11::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
timeval *timeout)
|
||||
{
|
||||
Q_D(QEventDispatcherX11);
|
||||
if (d->xfd > 0) {
|
||||
nfds = qMax(nfds - 1, d->xfd) + 1;
|
||||
FD_SET(d->xfd, readfds);
|
||||
}
|
||||
return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,86 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QEVENTDISPATCHER_X11_P_H
|
||||
#define QEVENTDISPATCHER_X11_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "private/qeventdispatcher_unix_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QEventDispatcherX11Private;
|
||||
|
||||
class QEventDispatcherX11 : public QEventDispatcherUNIX
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QEventDispatcherX11)
|
||||
|
||||
public:
|
||||
explicit QEventDispatcherX11(QObject *parent = 0);
|
||||
~QEventDispatcherX11();
|
||||
|
||||
bool processEvents(QEventLoop::ProcessEventsFlags flags);
|
||||
bool hasPendingEvents();
|
||||
|
||||
void flush();
|
||||
|
||||
void startingUp();
|
||||
void closingDown();
|
||||
|
||||
protected:
|
||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
timeval *timeout);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QEVENTDISPATCHER_X11_P_H
|
@ -1,368 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define QT_FATAL_ASSERT
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
#include "qfont.h"
|
||||
#include "qapplication.h"
|
||||
#include "qfontinfo.h"
|
||||
#include "qfontdatabase.h"
|
||||
#include "qfontmetrics.h"
|
||||
#include "qpaintdevice.h"
|
||||
#include "qtextcodec.h"
|
||||
#include "qiodevice.h"
|
||||
#include "qhash.h"
|
||||
|
||||
#include <private/qunicodetables_p.h>
|
||||
#include "qfont_p.h"
|
||||
#include "qfontengine_p.h"
|
||||
#include "qfontengine_x11_p.h"
|
||||
#include "qtextengine_p.h"
|
||||
|
||||
#include <private/qt_x11_p.h>
|
||||
#include "qx11info_x11.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define QFONTLOADER_DEBUG
|
||||
#define QFONTLOADER_DEBUG_VERBOSE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
double qt_pixelSize(double pointSize, int dpi)
|
||||
{
|
||||
if (pointSize < 0)
|
||||
return -1.;
|
||||
if (dpi == 75) // the stupid 75 dpi setting on X11
|
||||
dpi = 72;
|
||||
return (pointSize * dpi) /72.;
|
||||
}
|
||||
|
||||
double qt_pointSize(double pixelSize, int dpi)
|
||||
{
|
||||
if (pixelSize < 0)
|
||||
return -1.;
|
||||
if (dpi == 75) // the stupid 75 dpi setting on X11
|
||||
dpi = 72;
|
||||
return pixelSize * 72. / ((double) dpi);
|
||||
}
|
||||
|
||||
/*
|
||||
Removes wildcards from an XLFD.
|
||||
|
||||
Returns \a xlfd with all wildcards removed if a match for \a xlfd is
|
||||
found, otherwise it returns \a xlfd.
|
||||
*/
|
||||
static QByteArray qt_fixXLFD(const QByteArray &xlfd)
|
||||
{
|
||||
QByteArray ret = xlfd;
|
||||
int count = 0;
|
||||
char **fontNames =
|
||||
XListFonts(QX11Info::display(), xlfd, 32768, &count);
|
||||
if (count > 0)
|
||||
ret = fontNames[0];
|
||||
XFreeFontNames(fontNames);
|
||||
return ret ;
|
||||
}
|
||||
|
||||
typedef QHash<int, QString> FallBackHash;
|
||||
Q_GLOBAL_STATIC(FallBackHash, fallBackHash)
|
||||
|
||||
// Returns the user-configured fallback family for the specified script.
|
||||
QString qt_fallback_font_family(int script)
|
||||
{
|
||||
FallBackHash *hash = fallBackHash();
|
||||
return hash->value(script);
|
||||
}
|
||||
|
||||
// Sets the fallback family for the specified script.
|
||||
Q_WIDGETS_EXPORT void qt_x11_set_fallback_font_family(int script, const QString &family)
|
||||
{
|
||||
FallBackHash *hash = fallBackHash();
|
||||
if (!family.isEmpty())
|
||||
hash->insert(script, family);
|
||||
else
|
||||
hash->remove(script);
|
||||
}
|
||||
|
||||
int QFontPrivate::defaultEncodingID = -1;
|
||||
|
||||
void QFont::initialize()
|
||||
{
|
||||
extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp
|
||||
QTextCodec *codec = QTextCodec::codecForLocale();
|
||||
// determine the default encoding id using the locale, otherwise
|
||||
// fallback to latin1 (mib == 4)
|
||||
int mib = codec ? codec->mibEnum() : 4;
|
||||
|
||||
// for asian locales, use the mib for the font codec instead of the locale codec
|
||||
switch (mib) {
|
||||
case 38: // eucKR
|
||||
mib = 36;
|
||||
break;
|
||||
|
||||
case 2025: // GB2312
|
||||
mib = 57;
|
||||
break;
|
||||
|
||||
case 113: // GBK
|
||||
mib = -113;
|
||||
break;
|
||||
|
||||
case 114: // GB18030
|
||||
mib = -114;
|
||||
break;
|
||||
|
||||
case 2026: // Big5
|
||||
mib = -2026;
|
||||
break;
|
||||
|
||||
case 2101: // Big5-HKSCS
|
||||
mib = -2101;
|
||||
break;
|
||||
|
||||
case 16: // JIS7
|
||||
mib = 15;
|
||||
break;
|
||||
|
||||
case 17: // SJIS
|
||||
case 18: // eucJP
|
||||
mib = 63;
|
||||
break;
|
||||
}
|
||||
|
||||
// get the default encoding id for the locale encoding...
|
||||
QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib);
|
||||
}
|
||||
|
||||
void QFont::cleanup()
|
||||
{
|
||||
QFontCache::cleanup();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
X11 Only: Returns the screen with which this font is associated.
|
||||
*/
|
||||
int QFont::x11Screen() const
|
||||
{
|
||||
return d->screen;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
X11 Only: Associate the font with the specified \a screen.
|
||||
*/
|
||||
void QFont::x11SetScreen(int screen)
|
||||
{
|
||||
if (screen < 0) // assume default
|
||||
screen = QX11Info::appScreen();
|
||||
|
||||
if (screen == d->screen)
|
||||
return; // nothing to do
|
||||
|
||||
detach();
|
||||
d->screen = screen;
|
||||
}
|
||||
|
||||
Qt::HANDLE QFont::handle() const
|
||||
{
|
||||
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
|
||||
Q_ASSERT(engine != 0);
|
||||
if (engine->type() == QFontEngine::Multi)
|
||||
engine = static_cast<QFontEngineMulti *>(engine)->engine(0);
|
||||
if (engine->type() == QFontEngine::XLFD)
|
||||
return static_cast<QFontEngineXLFD *>(engine)->fontStruct()->fid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
FT_Face QFont::freetypeFace() const
|
||||
{
|
||||
#ifndef QT_NO_FREETYPE
|
||||
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
|
||||
if (engine->type() == QFontEngine::Multi)
|
||||
engine = static_cast<QFontEngineMulti *>(engine)->engine(0);
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
if (engine->type() == QFontEngine::Freetype) {
|
||||
const QFontEngineFT *ft = static_cast<const QFontEngineFT *>(engine);
|
||||
return ft->non_locked_face();
|
||||
} else
|
||||
#endif
|
||||
if (engine->type() == QFontEngine::XLFD) {
|
||||
const QFontEngineXLFD *xlfd = static_cast<const QFontEngineXLFD *>(engine);
|
||||
return xlfd->non_locked_face();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString QFont::rawName() const
|
||||
{
|
||||
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
|
||||
Q_ASSERT(engine != 0);
|
||||
if (engine->type() == QFontEngine::Multi)
|
||||
engine = static_cast<QFontEngineMulti *>(engine)->engine(0);
|
||||
if (engine->type() == QFontEngine::XLFD)
|
||||
return QString::fromLatin1(engine->name());
|
||||
return QString();
|
||||
}
|
||||
struct QtFontDesc;
|
||||
|
||||
void QFont::setRawName(const QString &name)
|
||||
{
|
||||
detach();
|
||||
|
||||
// from qfontdatabase_x11.cpp
|
||||
extern bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc);
|
||||
|
||||
if (!qt_fillFontDef(qt_fixXLFD(name.toLatin1()), &d->request, d->dpi, 0)) {
|
||||
qWarning("QFont::setRawName: Invalid XLFD: \"%s\"", name.toLatin1().constData());
|
||||
|
||||
setFamily(name);
|
||||
setRawMode(true);
|
||||
} else {
|
||||
resolve_mask = QFont::AllPropertiesResolved;
|
||||
}
|
||||
}
|
||||
|
||||
QString QFont::lastResortFamily() const
|
||||
{
|
||||
return QString::fromLatin1("Helvetica");
|
||||
}
|
||||
|
||||
QString QFont::defaultFamily() const
|
||||
{
|
||||
switch (d->request.styleHint) {
|
||||
case QFont::Times:
|
||||
return QString::fromLatin1("Times");
|
||||
|
||||
case QFont::Courier:
|
||||
return QString::fromLatin1("Courier");
|
||||
|
||||
case QFont::Monospace:
|
||||
return QString::fromLatin1("Courier New");
|
||||
|
||||
case QFont::Cursive:
|
||||
return QString::fromLatin1("Comic Sans MS");
|
||||
|
||||
case QFont::Fantasy:
|
||||
return QString::fromLatin1("Impact");
|
||||
|
||||
case QFont::Decorative:
|
||||
return QString::fromLatin1("Old English");
|
||||
|
||||
case QFont::Helvetica:
|
||||
case QFont::System:
|
||||
default:
|
||||
return QString::fromLatin1("Helvetica");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Returns a last resort raw font name for the font matching algorithm.
|
||||
This is used if even the last resort family is not available. It
|
||||
returns \e something, almost no matter what. The current
|
||||
implementation tries a wide variety of common fonts, returning the
|
||||
first one it finds. The implementation may change at any time.
|
||||
*/
|
||||
static const char * const tryFonts[] = {
|
||||
"-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-times-medium-r-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-lucida-medium-r-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-helvetica-*-*-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-courier-*-*-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-times-*-*-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-lucida-*-*-*-*-*-120-*-*-*-*-*-*",
|
||||
"-*-helvetica-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
"-*-courier-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
"-*-times-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
"-*-lucida-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
"-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
"6x13",
|
||||
"7x13",
|
||||
"8x13",
|
||||
"9x15",
|
||||
"fixed",
|
||||
0
|
||||
};
|
||||
|
||||
// Returns true if the font exists, false otherwise
|
||||
static bool fontExists(const QString &fontName)
|
||||
{
|
||||
int count;
|
||||
char **fontNames = XListFonts(QX11Info::display(), (char*)fontName.toLatin1().constData(), 32768, &count);
|
||||
if (fontNames) XFreeFontNames(fontNames);
|
||||
|
||||
return count != 0;
|
||||
}
|
||||
|
||||
QString QFont::lastResortFont() const
|
||||
{
|
||||
static QString last;
|
||||
|
||||
// already found
|
||||
if (! last.isNull())
|
||||
return last;
|
||||
|
||||
int i = 0;
|
||||
const char* f;
|
||||
|
||||
while ((f = tryFonts[i])) {
|
||||
last = QString::fromLatin1(f);
|
||||
|
||||
if (fontExists(last))
|
||||
return last;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
#if defined(CHECK_NULL)
|
||||
qFatal("QFontPrivate::lastResortFont: Cannot find any reasonable font");
|
||||
#endif
|
||||
return last;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,180 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QFONTENGINE_X11_P_H
|
||||
#define QFONTENGINE_X11_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
#include <private/qt_x11_p.h>
|
||||
|
||||
#include <private/qfontengine_ft_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFreetypeFace;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
class QFontEngineMultiXLFD : public QFontEngineMulti
|
||||
{
|
||||
public:
|
||||
QFontEngineMultiXLFD(const QFontDef &r, const QList<int> &l, int s);
|
||||
~QFontEngineMultiXLFD();
|
||||
|
||||
void loadEngine(int at);
|
||||
|
||||
private:
|
||||
QList<int> encodings;
|
||||
int screen;
|
||||
QFontDef request;
|
||||
};
|
||||
|
||||
/**
|
||||
* \internal The font engine for X Logical Font Description (XLFD) fonts, which is for X11 systems without freetype.
|
||||
*/
|
||||
class QFontEngineXLFD : public QFontEngine
|
||||
{
|
||||
public:
|
||||
QFontEngineXLFD(XFontStruct *f, const QByteArray &name, int mib);
|
||||
~QFontEngineXLFD();
|
||||
|
||||
virtual QFontEngine::FaceId faceId() const;
|
||||
QFontEngine::Properties properties() const;
|
||||
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
|
||||
virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
|
||||
virtual int synthesized() const;
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
|
||||
QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph);
|
||||
|
||||
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags);
|
||||
virtual QFixed ascent() const;
|
||||
virtual QFixed descent() const;
|
||||
virtual QFixed leading() const;
|
||||
virtual qreal maxCharWidth() const;
|
||||
virtual qreal minLeftBearing() const;
|
||||
virtual qreal minRightBearing() const;
|
||||
virtual QImage alphaMapForGlyph(glyph_t);
|
||||
|
||||
virtual inline Type type() const
|
||||
{ return QFontEngine::XLFD; }
|
||||
|
||||
virtual bool canRender(const QChar *string, int len);
|
||||
virtual const char *name() const;
|
||||
|
||||
inline XFontStruct *fontStruct() const
|
||||
{ return _fs; }
|
||||
|
||||
#ifndef QT_NO_FREETYPE
|
||||
FT_Face non_locked_face() const;
|
||||
glyph_t glyphIndexToFreetypeGlyphIndex(glyph_t g) const;
|
||||
#endif
|
||||
uint toUnicode(glyph_t g) const;
|
||||
|
||||
private:
|
||||
QBitmap bitmapForGlyphs(const QGlyphLayout &glyphs, const glyph_metrics_t &metrics, QTextItem::RenderFlags flags = 0);
|
||||
|
||||
XFontStruct *_fs;
|
||||
QByteArray _name;
|
||||
QTextCodec *_codec;
|
||||
int _cmap;
|
||||
int lbearing, rbearing;
|
||||
mutable QFontEngine::FaceId face_id;
|
||||
mutable QFreetypeFace *freetype;
|
||||
mutable int synth;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
|
||||
class Q_WIDGETS_EXPORT QFontEngineMultiFT : public QFontEngineMulti
|
||||
{
|
||||
public:
|
||||
QFontEngineMultiFT(QFontEngine *fe, FcPattern *firstEnginePattern, FcPattern *p, int s, const QFontDef &request);
|
||||
~QFontEngineMultiFT();
|
||||
|
||||
void loadEngine(int at);
|
||||
|
||||
private:
|
||||
QFontDef request;
|
||||
FcPattern *pattern;
|
||||
FcPattern *firstEnginePattern;
|
||||
FcFontSet *fontSet;
|
||||
int screen;
|
||||
int firstFontIndex; // first font in fontset
|
||||
};
|
||||
|
||||
class Q_WIDGETS_EXPORT QFontEngineX11FT : public QFontEngineFT
|
||||
{
|
||||
public:
|
||||
explicit QFontEngineX11FT(const QFontDef &fontDef) : QFontEngineFT(fontDef) {}
|
||||
explicit QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int screen);
|
||||
~QFontEngineX11FT();
|
||||
|
||||
QFontEngine *cloneWithSize(qreal pixelSize) const;
|
||||
|
||||
#ifndef QT_NO_XRENDER
|
||||
int xglyph_format;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *g, GlyphInfo *info, int glyphDataSize) const;
|
||||
virtual unsigned long allocateServerGlyphSet();
|
||||
virtual void freeServerGlyphSet(unsigned long id);
|
||||
};
|
||||
|
||||
#endif // QT_NO_FONTCONFIG
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QFONTENGINE_X11_P_H
|
@ -1,176 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "qkde_p.h"
|
||||
#include <QtCore/QLibrary>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/QSettings>
|
||||
#include "QtGui/qstylefactory.h"
|
||||
#include "qt_x11_p.h"
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*! \internal
|
||||
Gets the current KDE home path
|
||||
like "/home/troll/.kde"
|
||||
*/
|
||||
QString QKde::kdeHome()
|
||||
{
|
||||
static QString kdeHomePath;
|
||||
if (kdeHomePath.isEmpty()) {
|
||||
kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
|
||||
if (kdeHomePath.isEmpty()) {
|
||||
QDir homeDir(QDir::homePath());
|
||||
QString kdeConfDir(QLatin1String("/.kde"));
|
||||
if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
|
||||
kdeConfDir = QLatin1String("/.kde4");
|
||||
kdeHomePath = QDir::homePath() + kdeConfDir;
|
||||
}
|
||||
}
|
||||
return kdeHomePath;
|
||||
}
|
||||
|
||||
/*!\internal
|
||||
Reads the color from the config, and store it in the palette with the given color role if found
|
||||
*/
|
||||
static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key = QString())
|
||||
{
|
||||
QVariant variant = kdeSettings.value(kde4Key);
|
||||
if (!variant.isValid())
|
||||
QVariant variant = kdeSettings.value(kde3Key);
|
||||
if (variant.isValid()) {
|
||||
QStringList values = variant.toStringList();
|
||||
if (values.size() == 3) {
|
||||
int r = values[0].toInt();
|
||||
int g = values[1].toInt();
|
||||
int b = values[2].toInt();
|
||||
pal->setBrush(role, QColor(r, g, b));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!\internal
|
||||
Returns the KDE palette
|
||||
*/
|
||||
QPalette QKde::kdePalette()
|
||||
{
|
||||
const QSettings theKdeSettings(QKde::kdeHome() +
|
||||
QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
|
||||
QPalette pal;
|
||||
|
||||
// Setup KDE palette
|
||||
kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground"));
|
||||
kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background"));
|
||||
kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground"));
|
||||
kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground"));
|
||||
kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground"));
|
||||
kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground"));
|
||||
kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground"));
|
||||
kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground"));
|
||||
kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground"));
|
||||
kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor"));
|
||||
kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor"));
|
||||
//## TODO tooltip color
|
||||
|
||||
return pal;
|
||||
}
|
||||
|
||||
/*!\internal
|
||||
Returns the name of the QStyle to use.
|
||||
(read from the kde config if needed)
|
||||
*/
|
||||
QString QKde::kdeStyle()
|
||||
{
|
||||
if (X11->desktopVersion >= 4) {
|
||||
QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
|
||||
QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
|
||||
|
||||
QStringList availableStyles = QStyleFactory::keys();
|
||||
if(availableStyles.contains(style, Qt::CaseInsensitive))
|
||||
return style;
|
||||
}
|
||||
|
||||
if (X11->use_xrender)
|
||||
return QLatin1String("plastique");
|
||||
else
|
||||
return QLatin1String("windows");
|
||||
}
|
||||
|
||||
|
||||
int QKde::kdeToolButtonStyle()
|
||||
{
|
||||
QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
|
||||
QSettings::IniFormat);
|
||||
settings.beginGroup(QLatin1String("Toolbar style"));
|
||||
QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString();
|
||||
if (toolbarStyle == QLatin1String("TextBesideIcon"))
|
||||
return Qt::ToolButtonTextBesideIcon;
|
||||
else if (toolbarStyle == QLatin1String("TextOnly"))
|
||||
return Qt::ToolButtonTextOnly;
|
||||
else if (toolbarStyle == QLatin1String("TextUnderIcon"))
|
||||
return Qt::ToolButtonTextUnderIcon;
|
||||
|
||||
return Qt::ToolButtonTextBesideIcon;
|
||||
}
|
||||
|
||||
int QKde::kdeToolBarIconSize()
|
||||
{
|
||||
static int iconSize = -1;
|
||||
if (iconSize == -1) {
|
||||
QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
|
||||
QSettings::IniFormat);
|
||||
settings.beginGroup(QLatin1String("ToolbarIcons"));
|
||||
iconSize = settings.value(QLatin1String("Size")).toInt();
|
||||
}
|
||||
return iconSize;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //Q_WS_X11
|
||||
|
@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKDE_H
|
||||
#define QKDE_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtGui/QPalette>
|
||||
#include <QtWidgets/QIcon>
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
#if defined(Q_WS_X11)
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!\internal
|
||||
This namespace contains helper function to help KDE integration
|
||||
They are only used if we detect the use of KDE and the KDE platform plugin is not found (old KDE version)
|
||||
Or if the detected KDE version is KDE3
|
||||
*/
|
||||
namespace QKde {
|
||||
QString kdeHome();
|
||||
QString kdeStyle();
|
||||
QPalette kdePalette();
|
||||
int kdeToolButtonStyle();
|
||||
int kdeToolBarIconSize();
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // Q_WS_X11
|
||||
#endif // QKDE_H
|
File diff suppressed because it is too large
Load Diff
@ -1,489 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
// This file is auto-generated, do not edit!
|
||||
// (Generated using util/xkbdatagen)
|
||||
|
||||
static struct {
|
||||
const char *layout;
|
||||
const char *variant; // 0 means any variant
|
||||
Qt::LayoutDirection direction;
|
||||
QLocale::Language language;
|
||||
QLocale::Country country;
|
||||
} xkbLayoutData[] = {
|
||||
// name = us, description = U.S. English
|
||||
{ "us", "", Qt::LeftToRight, QLocale::English, QLocale::UnitedStates },
|
||||
// name = us:intl, description = U.S. English
|
||||
{ "us", "intl", Qt::LeftToRight, QLocale::English, QLocale::UnitedStates },
|
||||
// name = us:alt-intl, description = U.S. English
|
||||
{ "us", "alt-intl", Qt::LeftToRight, QLocale::English, QLocale::UnitedStates },
|
||||
// name = us:dvorak, description = U.S. English
|
||||
{ "us", "dvorak", Qt::LeftToRight, QLocale::English, QLocale::UnitedStates },
|
||||
// name = us:rus, description = U.S. English
|
||||
{ "us", "rus", Qt::LeftToRight, QLocale::Russian, QLocale::UnitedStates },
|
||||
// name = ara, description = Arabic
|
||||
{ "ara", "", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = ara:azerty, description = Arabic
|
||||
{ "ara", "azerty", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = ara:azerty_digits, description = Arabic
|
||||
{ "ara", "azerty_digits", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = ara:digits, description = Arabic
|
||||
{ "ara", "digits", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = ara:qwerty, description = Arabic
|
||||
{ "ara", "qwerty", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = ara:qwerty_digits, description = Arabic
|
||||
{ "ara", "qwerty_digits", Qt::RightToLeft, QLocale::Arabic, QLocale::UnitedArabEmirates },
|
||||
// name = al, description = Albania
|
||||
{ "al", "", Qt::LeftToRight, QLocale::Albanian, QLocale::Albania },
|
||||
// name = am, description = Armenia
|
||||
{ "am", "", Qt::LeftToRight, QLocale::Armenian, QLocale::Armenia },
|
||||
// name = am:phonetic, description = Armenia
|
||||
{ "am", "phonetic", Qt::LeftToRight, QLocale::Armenian, QLocale::Armenia },
|
||||
// name = az, description = Azerbaijan
|
||||
{ "az", "", Qt::LeftToRight, QLocale::Azerbaijani, QLocale::Azerbaijan },
|
||||
// name = az:cyrillic, description = Azerbaijan
|
||||
{ "az", "cyrillic", Qt::LeftToRight, QLocale::Azerbaijani, QLocale::Azerbaijan },
|
||||
// name = by, description = Belarus
|
||||
{ "by", "", Qt::LeftToRight, QLocale::Byelorussian, QLocale::Belarus },
|
||||
// name = by:winkeys, description = Belarus
|
||||
{ "by", "winkeys", Qt::LeftToRight, QLocale::Byelorussian, QLocale::Belarus },
|
||||
// name = be, description = Belgium
|
||||
{ "be", "", Qt::LeftToRight, QLocale::Dutch, QLocale::Belgium },
|
||||
// name = be:iso-alternate, description = Belgium
|
||||
{ "be", "iso-alternate", Qt::LeftToRight, QLocale::Dutch, QLocale::Belgium },
|
||||
// name = be:nodeadkeys, description = Belgium
|
||||
{ "be", "nodeadkeys", Qt::LeftToRight, QLocale::Dutch, QLocale::Belgium },
|
||||
// name = be:sundeadkeys, description = Belgium
|
||||
{ "be", "sundeadkeys", Qt::LeftToRight, QLocale::Dutch, QLocale::Belgium },
|
||||
// name = bd, description = Bangladesh
|
||||
{ "bd", "", Qt::LeftToRight, QLocale::Bengali, QLocale::Bangladesh },
|
||||
// name = bd:probhat, description = Bangladesh
|
||||
{ "bd", "probhat", Qt::LeftToRight, QLocale::Bengali, QLocale::Bangladesh },
|
||||
// name = in, description = India
|
||||
{ "in", "", Qt::LeftToRight, QLocale::Hindi, QLocale::India },
|
||||
// name = in:ben, description = India
|
||||
{ "in", "ben", Qt::LeftToRight, QLocale::Bengali, QLocale::India },
|
||||
// name = in:ben_probhat, description = India
|
||||
{ "in", "ben_probhat", Qt::LeftToRight, QLocale::Bengali, QLocale::India },
|
||||
// name = in:guj, description = India
|
||||
{ "in", "guj", Qt::LeftToRight, QLocale::Gujarati, QLocale::India },
|
||||
// name = in:guru, description = India
|
||||
{ "in", "guru", Qt::LeftToRight, QLocale::Punjabi, QLocale::India },
|
||||
// name = in:kan, description = India
|
||||
{ "in", "kan", Qt::LeftToRight, QLocale::Kannada, QLocale::India },
|
||||
// name = in:mal, description = India
|
||||
{ "in", "mal", Qt::LeftToRight, QLocale::Malayalam, QLocale::India },
|
||||
// name = in:ori, description = India
|
||||
{ "in", "ori", Qt::LeftToRight, QLocale::Oriya, QLocale::India },
|
||||
// name = in:tam_unicode, description = India
|
||||
{ "in", "tam_unicode", Qt::LeftToRight, QLocale::Tamil, QLocale::India },
|
||||
// name = in:tam_TAB, description = India
|
||||
{ "in", "tam_TAB", Qt::LeftToRight, QLocale::Tamil, QLocale::India },
|
||||
// name = in:tam_TSCII, description = India
|
||||
{ "in", "tam_TSCII", Qt::LeftToRight, QLocale::Tamil, QLocale::India },
|
||||
// name = in:tam, description = India
|
||||
{ "in", "tam", Qt::LeftToRight, QLocale::Tamil, QLocale::India },
|
||||
// name = in:tel, description = India
|
||||
{ "in", "tel", Qt::LeftToRight, QLocale::Telugu, QLocale::India },
|
||||
// name = in:urd, description = India
|
||||
{ "in", "urd", Qt::RightToLeft, QLocale::Urdu, QLocale::India },
|
||||
// name = ba, description = Bosnia and Herzegovina
|
||||
{ "ba", "", Qt::LeftToRight, QLocale::Bosnian, QLocale::BosniaAndHerzegowina },
|
||||
// name = br, description = Brazil
|
||||
{ "br", "", Qt::LeftToRight, QLocale::Portuguese, QLocale::Brazil },
|
||||
// name = br:nodeadkeys, description = Brazil
|
||||
{ "br", "nodeadkeys", Qt::LeftToRight, QLocale::Portuguese, QLocale::Brazil },
|
||||
// name = bg, description = Bulgaria
|
||||
{ "bg", "", Qt::LeftToRight, QLocale::Bulgarian, QLocale::Bulgaria },
|
||||
// name = bg:phonetic, description = Bulgaria
|
||||
{ "bg", "phonetic", Qt::LeftToRight, QLocale::Bulgarian, QLocale::Bulgaria },
|
||||
// name = mm, description = Myanmar
|
||||
{ "mm", "", Qt::LeftToRight, QLocale::Burmese, QLocale::Myanmar },
|
||||
// name = ca, description = Canada
|
||||
{ "ca", "", Qt::LeftToRight, QLocale::English, QLocale::Canada },
|
||||
// name = ca:fr-dvorak, description = Canada
|
||||
{ "ca", "fr-dvorak", Qt::LeftToRight, QLocale::French, QLocale::Canada },
|
||||
// name = ca:fr-legacy, description = Canada
|
||||
{ "ca", "fr-legacy", Qt::LeftToRight, QLocale::French, QLocale::Canada },
|
||||
// name = ca:multi, description = Canada
|
||||
{ "ca", "multi", Qt::LeftToRight, QLocale::English, QLocale::Canada },
|
||||
// name = ca:multi-2gr, description = Canada
|
||||
{ "ca", "multi-2gr", Qt::LeftToRight, QLocale::English, QLocale::Canada },
|
||||
// name = ca:ike, description = Canada
|
||||
{ "ca", "ike", Qt::LeftToRight, QLocale::Inuktitut, QLocale::Canada },
|
||||
// name = hr, description = Croatia
|
||||
{ "hr", "", Qt::LeftToRight, QLocale::Croatian, QLocale::Croatia },
|
||||
// name = hr:us, description = Croatia
|
||||
{ "hr", "us", Qt::LeftToRight, QLocale::Croatian, QLocale::Croatia },
|
||||
// name = cz, description = Czechia
|
||||
{ "cz", "", Qt::LeftToRight, QLocale::Czech, QLocale::CzechRepublic },
|
||||
// name = cz:bksl, description = Czechia
|
||||
{ "cz", "bksl", Qt::LeftToRight, QLocale::Czech, QLocale::CzechRepublic },
|
||||
// name = cz:qwerty, description = Czechia
|
||||
{ "cz", "qwerty", Qt::LeftToRight, QLocale::Czech, QLocale::CzechRepublic },
|
||||
// name = cz:qwerty_bksl, description = Czechia
|
||||
{ "cz", "qwerty_bksl", Qt::LeftToRight, QLocale::Czech, QLocale::CzechRepublic },
|
||||
// name = dk, description = Denmark
|
||||
{ "dk", "", Qt::LeftToRight, QLocale::Danish, QLocale::Denmark },
|
||||
// name = dk:nodeadkeys, description = Denmark
|
||||
{ "dk", "nodeadkeys", Qt::LeftToRight, QLocale::Danish, QLocale::Denmark },
|
||||
// name = nl, description = Netherlands
|
||||
{ "nl", "", Qt::LeftToRight, QLocale::Dutch, QLocale::Netherlands },
|
||||
// name = bt, description = Bhutan
|
||||
{ "bt", "", Qt::LeftToRight, QLocale::Bhutani, QLocale::Bhutan },
|
||||
// name = ee, description = Estonia
|
||||
{ "ee", "", Qt::LeftToRight, QLocale::Estonian, QLocale::Estonia },
|
||||
// name = ee:nodeadkeys, description = Estonia
|
||||
{ "ee", "nodeadkeys", Qt::LeftToRight, QLocale::Estonian, QLocale::Estonia },
|
||||
// name = ir, description = Iran
|
||||
{ "ir", "", Qt::RightToLeft, QLocale::Persian, QLocale::Iran },
|
||||
// name = fo, description = Faroe Islands
|
||||
{ "fo", "", Qt::LeftToRight, QLocale::Faroese, QLocale::FaroeIslands },
|
||||
// name = fo:nodeadkeys, description = Faroe Islands
|
||||
{ "fo", "nodeadkeys", Qt::LeftToRight, QLocale::Faroese, QLocale::FaroeIslands },
|
||||
// name = fi, description = Finland
|
||||
{ "fi", "", Qt::LeftToRight, QLocale::Finnish, QLocale::Finland },
|
||||
// name = fi:nodeadkeys, description = Finland
|
||||
{ "fi", "nodeadkeys", Qt::LeftToRight, QLocale::Finnish, QLocale::Finland },
|
||||
// name = fi:smi, description = Finland
|
||||
{ "fi", "smi", Qt::LeftToRight, QLocale::Finnish, QLocale::Finland },
|
||||
// name = fr, description = France
|
||||
{ "fr", "", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:nodeadkeys, description = France
|
||||
{ "fr", "nodeadkeys", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:sundeadkeys, description = France
|
||||
{ "fr", "sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:latin9, description = France
|
||||
{ "fr", "latin9", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:latin9_nodeadkeys, description = France
|
||||
{ "fr", "latin9_nodeadkeys", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:latin9_sundeadkeys, description = France
|
||||
{ "fr", "latin9_sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = fr:dvorak, description = France
|
||||
{ "fr", "dvorak", Qt::LeftToRight, QLocale::French, QLocale::France },
|
||||
// name = ge, description = Georgia
|
||||
{ "ge", "", Qt::LeftToRight, QLocale::Georgian, QLocale::Georgia },
|
||||
// name = ge:ru, description = Georgia
|
||||
{ "ge", "ru", Qt::LeftToRight, QLocale::Russian, QLocale::Georgia },
|
||||
// name = de, description = Germany
|
||||
{ "de", "", Qt::LeftToRight, QLocale::German, QLocale::Germany },
|
||||
// name = de:deadacute, description = Germany
|
||||
{ "de", "deadacute", Qt::LeftToRight, QLocale::German, QLocale::Germany },
|
||||
// name = de:deadgraveacute, description = Germany
|
||||
{ "de", "deadgraveacute", Qt::LeftToRight, QLocale::German, QLocale::Germany },
|
||||
// name = de:nodeadkeys, description = Germany
|
||||
{ "de", "nodeadkeys", Qt::LeftToRight, QLocale::German, QLocale::Germany },
|
||||
// name = de:ro, description = Germany
|
||||
{ "de", "ro", Qt::LeftToRight, QLocale::Romanian, QLocale::Germany },
|
||||
// name = de:ro_nodeadkeys, description = Germany
|
||||
{ "de", "ro_nodeadkeys", Qt::LeftToRight, QLocale::Romanian, QLocale::Germany },
|
||||
// name = de:dvorak, description = Germany
|
||||
{ "de", "dvorak", Qt::LeftToRight, QLocale::German, QLocale::Germany },
|
||||
// name = gr, description = Greece
|
||||
{ "gr", "", Qt::LeftToRight, QLocale::Greek, QLocale::Greece },
|
||||
// name = gr:extended, description = Greece
|
||||
{ "gr", "extended", Qt::LeftToRight, QLocale::Greek, QLocale::Greece },
|
||||
// name = gr:nodeadkeys, description = Greece
|
||||
{ "gr", "nodeadkeys", Qt::LeftToRight, QLocale::Greek, QLocale::Greece },
|
||||
// name = gr:polytonic, description = Greece
|
||||
{ "gr", "polytonic", Qt::LeftToRight, QLocale::Greek, QLocale::Greece },
|
||||
// name = hu, description = Hungary
|
||||
{ "hu", "", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:standard, description = Hungary
|
||||
{ "hu", "standard", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:nodeadkeys, description = Hungary
|
||||
{ "hu", "nodeadkeys", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:qwerty, description = Hungary
|
||||
{ "hu", "qwerty", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwertz_comma_dead, description = Hungary
|
||||
{ "hu", "101_qwertz_comma_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwertz_comma_nodead, description = Hungary
|
||||
{ "hu", "101_qwertz_comma_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwertz_dot_dead, description = Hungary
|
||||
{ "hu", "101_qwertz_dot_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwertz_dot_nodead, description = Hungary
|
||||
{ "hu", "101_qwertz_dot_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwerty_comma_dead, description = Hungary
|
||||
{ "hu", "101_qwerty_comma_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwerty_comma_nodead, description = Hungary
|
||||
{ "hu", "101_qwerty_comma_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwerty_dot_dead, description = Hungary
|
||||
{ "hu", "101_qwerty_dot_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:101_qwerty_dot_nodead, description = Hungary
|
||||
{ "hu", "101_qwerty_dot_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwertz_comma_dead, description = Hungary
|
||||
{ "hu", "102_qwertz_comma_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwertz_comma_nodead, description = Hungary
|
||||
{ "hu", "102_qwertz_comma_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwertz_dot_dead, description = Hungary
|
||||
{ "hu", "102_qwertz_dot_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwertz_dot_nodead, description = Hungary
|
||||
{ "hu", "102_qwertz_dot_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwerty_comma_dead, description = Hungary
|
||||
{ "hu", "102_qwerty_comma_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwerty_comma_nodead, description = Hungary
|
||||
{ "hu", "102_qwerty_comma_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwerty_dot_dead, description = Hungary
|
||||
{ "hu", "102_qwerty_dot_dead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = hu:102_qwerty_dot_nodead, description = Hungary
|
||||
{ "hu", "102_qwerty_dot_nodead", Qt::LeftToRight, QLocale::Hungarian, QLocale::Hungary },
|
||||
// name = is, description = Iceland
|
||||
{ "is", "", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland },
|
||||
// name = is:Sundeadkeys, description = Iceland
|
||||
{ "is", "Sundeadkeys", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland },
|
||||
// name = is:nodeadkeys, description = Iceland
|
||||
{ "is", "nodeadkeys", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland },
|
||||
// name = il, description = Israel
|
||||
{ "il", "", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
|
||||
// name = il:lyx, description = Israel
|
||||
{ "il", "lyx", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
|
||||
// name = il:si1452, description = Israel
|
||||
{ "il", "si1452", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
|
||||
// name = il:phonetic, description = Israel
|
||||
{ "il", "phonetic", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
|
||||
// name = it, description = Italy
|
||||
{ "it", "", Qt::LeftToRight, QLocale::Italian, QLocale::Italy },
|
||||
// name = it:nodeadkeys, description = Italy
|
||||
{ "it", "nodeadkeys", Qt::LeftToRight, QLocale::Italian, QLocale::Italy },
|
||||
// name = jp, description = Japan
|
||||
{ "jp", "", Qt::LeftToRight, QLocale::Japanese, QLocale::Japan },
|
||||
// name = kg, description = Kyrgyzstan
|
||||
{ "kg", "", Qt::LeftToRight, QLocale::Kirghiz, QLocale::Kyrgyzstan },
|
||||
// name = la, description = Laos
|
||||
{ "la", "", Qt::LeftToRight, QLocale::Laothian, QLocale::Lao },
|
||||
// name = latam, description = Latin American
|
||||
{ "latam", "", Qt::LeftToRight, QLocale::Spanish, QLocale::Mexico },
|
||||
// name = latam:nodeadkeys, description = Latin American
|
||||
{ "latam", "nodeadkeys", Qt::LeftToRight, QLocale::Spanish, QLocale::Mexico },
|
||||
// name = latam:sundeadkeys, description = Latin American
|
||||
{ "latam", "sundeadkeys", Qt::LeftToRight, QLocale::Spanish, QLocale::Mexico },
|
||||
// name = lt, description = Lithuania
|
||||
{ "lt", "", Qt::LeftToRight, QLocale::Lithuanian, QLocale::Lithuania },
|
||||
// name = lt:std, description = Lithuania
|
||||
{ "lt", "std", Qt::LeftToRight, QLocale::Lithuanian, QLocale::Lithuania },
|
||||
// name = lt:us, description = Lithuania
|
||||
{ "lt", "us", Qt::LeftToRight, QLocale::Lithuanian, QLocale::Lithuania },
|
||||
// name = lv, description = Latvia
|
||||
{ "lv", "", Qt::LeftToRight, QLocale::Latvian, QLocale::Latvia },
|
||||
// name = lv:apostrophe, description = Latvia
|
||||
{ "lv", "apostrophe", Qt::LeftToRight, QLocale::Latvian, QLocale::Latvia },
|
||||
// name = lv:tilde, description = Latvia
|
||||
{ "lv", "tilde", Qt::LeftToRight, QLocale::Latvian, QLocale::Latvia },
|
||||
// name = lv:fkey, description = Latvia
|
||||
{ "lv", "fkey", Qt::LeftToRight, QLocale::Latvian, QLocale::Latvia },
|
||||
// name = mao, description = Maori
|
||||
{ "mao", "", Qt::LeftToRight, QLocale::Maori, QLocale::NewZealand },
|
||||
// name = mkd, description = Macedonian
|
||||
{ "mkd", "", Qt::LeftToRight, QLocale::Macedonian, QLocale::Macedonia },
|
||||
// name = mkd:nodeadkeys, description = Macedonian
|
||||
{ "mkd", "nodeadkeys", Qt::LeftToRight, QLocale::Macedonian, QLocale::Macedonia },
|
||||
// name = mt, description = Malta
|
||||
{ "mt", "", Qt::LeftToRight, QLocale::Maltese, QLocale::Malta },
|
||||
// name = mt:us, description = Malta
|
||||
{ "mt", "us", Qt::LeftToRight, QLocale::Maltese, QLocale::Malta },
|
||||
// name = mn, description = Mongolia
|
||||
{ "mn", "", Qt::LeftToRight, QLocale::Mongolian, QLocale::Mongolia },
|
||||
// name = no, description = Norway
|
||||
{ "no", "", Qt::LeftToRight, QLocale::Norwegian, QLocale::Norway },
|
||||
// name = no:nodeadkeys, description = Norway
|
||||
{ "no", "nodeadkeys", Qt::LeftToRight, QLocale::Norwegian, QLocale::Norway },
|
||||
// name = no:dvorak, description = Norway
|
||||
{ "no", "dvorak", Qt::LeftToRight, QLocale::Norwegian, QLocale::Norway },
|
||||
// name = no:smi, description = Norway
|
||||
{ "no", "smi", Qt::LeftToRight, QLocale::Norwegian, QLocale::Norway },
|
||||
// name = no:smi_nodeadkeys, description = Norway
|
||||
{ "no", "smi_nodeadkeys", Qt::LeftToRight, QLocale::Norwegian, QLocale::Norway },
|
||||
// name = pl, description = Poland
|
||||
{ "pl", "", Qt::LeftToRight, QLocale::Polish, QLocale::Poland },
|
||||
// name = pl:qwertz, description = Poland
|
||||
{ "pl", "qwertz", Qt::LeftToRight, QLocale::Polish, QLocale::Poland },
|
||||
// name = pl:dvorak, description = Poland
|
||||
{ "pl", "dvorak", Qt::LeftToRight, QLocale::Polish, QLocale::Poland },
|
||||
// name = pl:dvorak_quotes, description = Poland
|
||||
{ "pl", "dvorak_quotes", Qt::LeftToRight, QLocale::Polish, QLocale::Poland },
|
||||
// name = pl:dvorak_altquotes, description = Poland
|
||||
{ "pl", "dvorak_altquotes", Qt::LeftToRight, QLocale::Polish, QLocale::Poland },
|
||||
// name = pt, description = Portugal
|
||||
{ "pt", "", Qt::LeftToRight, QLocale::Portuguese, QLocale::Portugal },
|
||||
// name = pt:nodeadkeys, description = Portugal
|
||||
{ "pt", "nodeadkeys", Qt::LeftToRight, QLocale::Portuguese, QLocale::Portugal },
|
||||
// name = pt:sundeadkeys, description = Portugal
|
||||
{ "pt", "sundeadkeys", Qt::LeftToRight, QLocale::Portuguese, QLocale::Portugal },
|
||||
// name = ro, description = Romania
|
||||
{ "ro", "", Qt::LeftToRight, QLocale::Romanian, QLocale::Romania },
|
||||
// name = ro:us, description = Romania
|
||||
{ "ro", "us", Qt::LeftToRight, QLocale::English, QLocale::Romania },
|
||||
// name = ro:de, description = Romania
|
||||
{ "ro", "de", Qt::LeftToRight, QLocale::German, QLocale::Romania },
|
||||
// name = ru, description = Russia
|
||||
{ "ru", "", Qt::LeftToRight, QLocale::Russian, QLocale::RussianFederation },
|
||||
// name = ru:phonetic, description = Russia
|
||||
{ "ru", "phonetic", Qt::LeftToRight, QLocale::Russian, QLocale::RussianFederation },
|
||||
// name = ru:typewriter, description = Russia
|
||||
{ "ru", "typewriter", Qt::LeftToRight, QLocale::Russian, QLocale::RussianFederation },
|
||||
// name = ru:winkeys, description = Russia
|
||||
{ "ru", "winkeys", Qt::LeftToRight, QLocale::Russian, QLocale::RussianFederation },
|
||||
// name = srp, description = Serbian
|
||||
{ "srp", "", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:yz, description = Serbian
|
||||
{ "srp", "yz", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:latin, description = Serbian
|
||||
{ "srp", "latin", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:latinunicode, description = Serbian
|
||||
{ "srp", "latinunicode", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:latinyz, description = Serbian
|
||||
{ "srp", "latinyz", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:latinunicodeyz, description = Serbian
|
||||
{ "srp", "latinunicodeyz", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:alternatequotes, description = Serbian
|
||||
{ "srp", "alternatequotes", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = srp:latinalternatequotes, description = Serbian
|
||||
{ "srp", "latinalternatequotes", Qt::LeftToRight, QLocale::Serbian, QLocale::SerbiaAndMontenegro },
|
||||
// name = si, description = Slovenia
|
||||
{ "si", "", Qt::LeftToRight, QLocale::Slovenian, QLocale::Slovenia },
|
||||
// name = sk, description = Slovakia
|
||||
{ "sk", "", Qt::LeftToRight, QLocale::Slovak, QLocale::Slovakia },
|
||||
// name = sk:bksl, description = Slovakia
|
||||
{ "sk", "bksl", Qt::LeftToRight, QLocale::Slovak, QLocale::Slovakia },
|
||||
// name = sk:qwerty, description = Slovakia
|
||||
{ "sk", "qwerty", Qt::LeftToRight, QLocale::Slovak, QLocale::Slovakia },
|
||||
// name = sk:qwerty_bksl, description = Slovakia
|
||||
{ "sk", "qwerty_bksl", Qt::LeftToRight, QLocale::Slovak, QLocale::Slovakia },
|
||||
// name = es, description = Spain
|
||||
{ "es", "", Qt::LeftToRight, QLocale::Spanish, QLocale::Spain },
|
||||
// name = es:nodeadkeys, description = Spain
|
||||
{ "es", "nodeadkeys", Qt::LeftToRight, QLocale::Spanish, QLocale::Spain },
|
||||
// name = es:sundeadkeys, description = Spain
|
||||
{ "es", "sundeadkeys", Qt::LeftToRight, QLocale::Spanish, QLocale::Spain },
|
||||
// name = es:dvorak, description = Spain
|
||||
{ "es", "dvorak", Qt::LeftToRight, QLocale::Spanish, QLocale::Spain },
|
||||
// name = se, description = Sweden
|
||||
{ "se", "", Qt::LeftToRight, QLocale::Swedish, QLocale::Sweden },
|
||||
// name = se:nodeadkeys, description = Sweden
|
||||
{ "se", "nodeadkeys", Qt::LeftToRight, QLocale::Swedish, QLocale::Sweden },
|
||||
// name = se:dvorak, description = Sweden
|
||||
{ "se", "dvorak", Qt::LeftToRight, QLocale::Swedish, QLocale::Sweden },
|
||||
// name = se:rus, description = Sweden
|
||||
{ "se", "rus", Qt::LeftToRight, QLocale::Russian, QLocale::Sweden },
|
||||
// name = se:rus_nodeadkeys, description = Sweden
|
||||
{ "se", "rus_nodeadkeys", Qt::LeftToRight, QLocale::Russian, QLocale::Sweden },
|
||||
// name = se:smi, description = Sweden
|
||||
{ "se", "smi", Qt::LeftToRight, QLocale::Swedish, QLocale::Sweden },
|
||||
// name = ch, description = Switzerland
|
||||
{ "ch", "", Qt::LeftToRight, QLocale::German, QLocale::Switzerland },
|
||||
// name = ch:de_nodeadkeys, description = Switzerland
|
||||
{ "ch", "de_nodeadkeys", Qt::LeftToRight, QLocale::German, QLocale::Switzerland },
|
||||
// name = ch:de_sundeadkeys, description = Switzerland
|
||||
{ "ch", "de_sundeadkeys", Qt::LeftToRight, QLocale::German, QLocale::Switzerland },
|
||||
// name = ch:fr, description = Switzerland
|
||||
{ "ch", "fr", Qt::LeftToRight, QLocale::French, QLocale::Switzerland },
|
||||
// name = ch:fr_nodeadkeys, description = Switzerland
|
||||
{ "ch", "fr_nodeadkeys", Qt::LeftToRight, QLocale::French, QLocale::Switzerland },
|
||||
// name = ch:fr_sundeadkeys, description = Switzerland
|
||||
{ "ch", "fr_sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::Switzerland },
|
||||
// name = sy, description = Syria
|
||||
{ "sy", "", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
|
||||
// name = sy:syc, description = Syria
|
||||
{ "sy", "syc", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
|
||||
// name = sy:syc_phonetic, description = Syria
|
||||
{ "sy", "syc_phonetic", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
|
||||
// name = tj, description = Tajikistan
|
||||
{ "tj", "", Qt::LeftToRight, QLocale::Tajik, QLocale::Tajikistan },
|
||||
// name = lk, description = Sri Lanka
|
||||
{ "lk", "", Qt::LeftToRight, QLocale::Singhalese, QLocale::SriLanka },
|
||||
// name = lk:tam_unicode, description = Sri Lanka
|
||||
{ "lk", "tam_unicode", Qt::LeftToRight, QLocale::Tamil, QLocale::SriLanka },
|
||||
// name = lk:tam_TAB, description = Sri Lanka
|
||||
{ "lk", "tam_TAB", Qt::LeftToRight, QLocale::Tamil, QLocale::SriLanka },
|
||||
// name = lk:tam_TSCII, description = Sri Lanka
|
||||
{ "lk", "tam_TSCII", Qt::LeftToRight, QLocale::Tamil, QLocale::SriLanka },
|
||||
// name = lk:sin_phonetic, description = Sri Lanka
|
||||
{ "lk", "sin_phonetic", Qt::LeftToRight, QLocale::Singhalese, QLocale::SriLanka },
|
||||
// name = th, description = Thailand
|
||||
{ "th", "", Qt::LeftToRight, QLocale::Thai, QLocale::Thailand },
|
||||
// name = th:tis, description = Thailand
|
||||
{ "th", "tis", Qt::LeftToRight, QLocale::Thai, QLocale::Thailand },
|
||||
// name = th:pat, description = Thailand
|
||||
{ "th", "pat", Qt::LeftToRight, QLocale::Thai, QLocale::Thailand },
|
||||
// name = tr, description = Turkish
|
||||
{ "tr", "", Qt::LeftToRight, QLocale::Turkish, QLocale::Turkey },
|
||||
// name = tr:f, description = Turkish
|
||||
{ "tr", "f", Qt::LeftToRight, QLocale::Turkish, QLocale::Turkey },
|
||||
// name = tr:alt, description = Turkish
|
||||
{ "tr", "alt", Qt::LeftToRight, QLocale::Turkish, QLocale::Turkey },
|
||||
// name = ua, description = Ukraine
|
||||
{ "ua", "", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = ua:phonetic, description = Ukraine
|
||||
{ "ua", "phonetic", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = ua:typewriter, description = Ukraine
|
||||
{ "ua", "typewriter", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = ua:winkeys, description = Ukraine
|
||||
{ "ua", "winkeys", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = ua:rstu, description = Ukraine
|
||||
{ "ua", "rstu", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = ua:rstu_ru, description = Ukraine
|
||||
{ "ua", "rstu_ru", Qt::LeftToRight, QLocale::Ukrainian, QLocale::Ukraine },
|
||||
// name = gb, description = United Kingdom
|
||||
{ "gb", "", Qt::LeftToRight, QLocale::English, QLocale::UnitedKingdom },
|
||||
// name = gb:intl, description = United Kingdom
|
||||
{ "gb", "intl", Qt::LeftToRight, QLocale::English, QLocale::UnitedKingdom },
|
||||
// name = gb:dvorak, description = United Kingdom
|
||||
{ "gb", "dvorak", Qt::LeftToRight, QLocale::English, QLocale::UnitedKingdom },
|
||||
// name = uz, description = Uzbekistan
|
||||
{ "uz", "", Qt::LeftToRight, QLocale::Uzbek, QLocale::Uzbekistan },
|
||||
// name = vn, description = Vietnam
|
||||
{ "vn", "", Qt::LeftToRight, QLocale::Vietnamese, QLocale::VietNam },
|
||||
// name = nec_vndr/jp, description = PC-98xx Series
|
||||
{ "nec_vndr/jp", "", Qt::LeftToRight, QLocale::Japanese, QLocale::Japan },
|
||||
// name = ie, description = Ireland
|
||||
{ "ie", "", Qt::LeftToRight, QLocale::Irish, QLocale::Ireland },
|
||||
// name = ie:CloGaelach, description = Ireland
|
||||
{ "ie", "CloGaelach", Qt::LeftToRight, QLocale::Gaelic, QLocale::Ireland },
|
||||
// name = ie:UnicodeExpert, description = Ireland
|
||||
{ "ie", "UnicodeExpert", Qt::LeftToRight, QLocale::Irish, QLocale::Ireland },
|
||||
// name = ie:ogam, description = Ireland
|
||||
{ "ie", "ogam", Qt::LeftToRight, QLocale::Gaelic, QLocale::Ireland },
|
||||
// name = ie:ogam_is434, description = Ireland
|
||||
{ "ie", "ogam_is434", Qt::LeftToRight, QLocale::Gaelic, QLocale::Ireland },
|
||||
// name = pk, description = Pakistan
|
||||
{ "pk", "", Qt::RightToLeft, QLocale::Urdu, QLocale::Pakistan },
|
||||
{ 0, 0, Qt::LeftToRight, QLocale::C, QLocale::AnyCountry }
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qpaintdevice.h"
|
||||
#include "qpainter.h"
|
||||
#include "qwidget.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qapplication.h"
|
||||
#include <private/qt_x11_p.h>
|
||||
#include "qx11info_x11.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*! \internal
|
||||
|
||||
Returns the X11 Drawable of the paint device. 0 is returned if it
|
||||
can't be obtained.
|
||||
*/
|
||||
|
||||
Drawable Q_WIDGETS_EXPORT qt_x11Handle(const QPaintDevice *pd)
|
||||
{
|
||||
if (!pd) return 0;
|
||||
if (pd->devType() == QInternal::Widget)
|
||||
return static_cast<const QWidget *>(pd)->handle();
|
||||
else if (pd->devType() == QInternal::Pixmap)
|
||||
return static_cast<const QPixmap *>(pd)->handle();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\relates QPaintDevice
|
||||
|
||||
Returns the QX11Info structure for the \a pd paint device. 0 is
|
||||
returned if it can't be obtained.
|
||||
*/
|
||||
const Q_WIDGETS_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd)
|
||||
{
|
||||
if (!pd) return 0;
|
||||
if (pd->devType() == QInternal::Widget)
|
||||
return &static_cast<const QWidget *>(pd)->x11Info();
|
||||
else if (pd->devType() == QInternal::Pixmap)
|
||||
return &static_cast<const QPixmap *>(pd)->x11Info();
|
||||
return 0;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,246 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPAINTENGINE_X11_P_H
|
||||
#define QPAINTENGINE_X11_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtGui/qpaintengine.h"
|
||||
#include "QtGui/qregion.h"
|
||||
#include "QtGui/qpen.h"
|
||||
#include "QtCore/qpoint.h"
|
||||
#include "private/qpaintengine_p.h"
|
||||
#include "private/qpainter_p.h"
|
||||
#include "private/qpolygonclipper_p.h"
|
||||
|
||||
typedef unsigned long Picture;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QX11PaintEnginePrivate;
|
||||
class QFontEngineFT;
|
||||
class QXRenderTessellator;
|
||||
|
||||
struct qt_float_point
|
||||
{
|
||||
qreal x, y;
|
||||
};
|
||||
|
||||
class QX11PaintEngine : public QPaintEngine
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QX11PaintEngine)
|
||||
public:
|
||||
QX11PaintEngine();
|
||||
~QX11PaintEngine();
|
||||
|
||||
bool begin(QPaintDevice *pdev);
|
||||
bool end();
|
||||
|
||||
void updateState(const QPaintEngineState &state);
|
||||
|
||||
void updatePen(const QPen &pen);
|
||||
void updateBrush(const QBrush &brush, const QPointF &pt);
|
||||
void updateRenderHints(QPainter::RenderHints hints);
|
||||
void updateFont(const QFont &font);
|
||||
void updateMatrix(const QTransform &matrix);
|
||||
void updateClipRegion_dev(const QRegion ®ion, Qt::ClipOperation op);
|
||||
|
||||
void drawLines(const QLine *lines, int lineCount);
|
||||
void drawLines(const QLineF *lines, int lineCount);
|
||||
|
||||
void drawRects(const QRect *rects, int rectCount);
|
||||
void drawRects(const QRectF *rects, int rectCount);
|
||||
|
||||
void drawPoints(const QPoint *points, int pointCount);
|
||||
void drawPoints(const QPointF *points, int pointCount);
|
||||
|
||||
void drawEllipse(const QRect &r);
|
||||
void drawEllipse(const QRectF &r);
|
||||
|
||||
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
||||
inline void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
|
||||
{ QPaintEngine::drawPolygon(points, pointCount, mode); }
|
||||
|
||||
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
||||
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
||||
void drawPath(const QPainterPath &path);
|
||||
void drawTextItem(const QPointF &p, const QTextItem &textItem);
|
||||
void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
|
||||
virtual Qt::HANDLE handle() const;
|
||||
inline Type type() const { return QPaintEngine::X11; }
|
||||
|
||||
QPainter::RenderHints supportedRenderHints() const;
|
||||
|
||||
protected:
|
||||
QX11PaintEngine(QX11PaintEnginePrivate &dptr);
|
||||
|
||||
void drawXLFD(const QPointF &p, const QTextItemInt &si);
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
void drawFreetype(const QPointF &p, const QTextItemInt &si);
|
||||
#endif
|
||||
|
||||
friend class QPixmap;
|
||||
friend class QFontEngineBox;
|
||||
friend Q_WIDGETS_EXPORT GC qt_x11_get_pen_gc(QPainter *);
|
||||
friend Q_WIDGETS_EXPORT GC qt_x11_get_brush_gc(QPainter *);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QX11PaintEngine)
|
||||
};
|
||||
|
||||
class QX11PaintEnginePrivate : public QPaintEnginePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QX11PaintEngine)
|
||||
public:
|
||||
QX11PaintEnginePrivate()
|
||||
{
|
||||
scrn = -1;
|
||||
hd = 0;
|
||||
picture = 0;
|
||||
gc = gc_brush = 0;
|
||||
dpy = 0;
|
||||
xinfo = 0;
|
||||
txop = QTransform::TxNone;
|
||||
has_clipping = false;
|
||||
render_hints = 0;
|
||||
xform_scale = 1;
|
||||
#ifndef QT_NO_XRENDER
|
||||
tessellator = 0;
|
||||
#endif
|
||||
}
|
||||
enum GCMode {
|
||||
PenGC,
|
||||
BrushGC
|
||||
};
|
||||
|
||||
void init();
|
||||
void fillPolygon_translated(const QPointF *points, int pointCount, GCMode gcMode,
|
||||
QPaintEngine::PolygonDrawMode mode);
|
||||
void fillPolygon_dev(const QPointF *points, int pointCount, GCMode gcMode,
|
||||
QPaintEngine::PolygonDrawMode mode);
|
||||
void fillPath(const QPainterPath &path, GCMode gcmode, bool transform);
|
||||
void strokePolygon_dev(const QPointF *points, int pointCount, bool close);
|
||||
void strokePolygon_translated(const QPointF *points, int pointCount, bool close);
|
||||
void setupAdaptedOrigin(const QPoint &p);
|
||||
void resetAdaptedOrigin();
|
||||
void decidePathFallback() {
|
||||
use_path_fallback = has_alpha_brush
|
||||
|| has_alpha_pen
|
||||
|| has_custom_pen
|
||||
|| has_complex_xform
|
||||
|| (render_hints & QPainter::Antialiasing);
|
||||
}
|
||||
void decideCoordAdjust() {
|
||||
adjust_coords = !(render_hints & QPainter::Antialiasing)
|
||||
&& (has_alpha_pen
|
||||
|| (has_alpha_brush && has_pen && !has_alpha_pen)
|
||||
|| (cpen.style() > Qt::SolidLine));
|
||||
}
|
||||
void clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly);
|
||||
void systemStateChanged();
|
||||
|
||||
Display *dpy;
|
||||
int scrn;
|
||||
int pdev_depth;
|
||||
Qt::HANDLE hd;
|
||||
QPixmap brush_pm;
|
||||
#if !defined (QT_NO_XRENDER)
|
||||
Qt::HANDLE picture;
|
||||
Qt::HANDLE current_brush;
|
||||
QPixmap bitmap_texture;
|
||||
int composition_mode;
|
||||
#else
|
||||
Qt::HANDLE picture;
|
||||
#endif
|
||||
GC gc;
|
||||
GC gc_brush;
|
||||
|
||||
QPen cpen;
|
||||
QBrush cbrush;
|
||||
QRegion crgn;
|
||||
QTransform matrix;
|
||||
qreal opacity;
|
||||
|
||||
uint has_complex_xform : 1;
|
||||
uint has_scaling_xform : 1;
|
||||
uint has_non_scaling_xform : 1;
|
||||
uint has_custom_pen : 1;
|
||||
uint use_path_fallback : 1;
|
||||
uint adjust_coords : 1;
|
||||
uint has_clipping : 1;
|
||||
uint adapted_brush_origin : 1;
|
||||
uint adapted_pen_origin : 1;
|
||||
uint has_pen : 1;
|
||||
uint has_brush : 1;
|
||||
uint has_texture : 1;
|
||||
uint has_alpha_texture : 1;
|
||||
uint has_pattern : 1;
|
||||
uint has_alpha_pen : 1;
|
||||
uint has_alpha_brush : 1;
|
||||
uint render_hints;
|
||||
|
||||
const QX11Info *xinfo;
|
||||
QPointF bg_origin;
|
||||
QTransform::TransformationType txop;
|
||||
qreal xform_scale;
|
||||
QPolygonClipper<qt_float_point, qt_float_point, float> polygonClipper;
|
||||
|
||||
int xlibMaxLinePoints;
|
||||
#ifndef QT_NO_XRENDER
|
||||
QXRenderTessellator *tessellator;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPAINTENGINE_X11_P_H
|
File diff suppressed because it is too large
Load Diff
@ -1,156 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPIXMAPDATA_X11_P_H
|
||||
#define QPIXMAPDATA_X11_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGui/qplatformpixmap_qpa.h>
|
||||
#include <QtGui/qplatformpixmapfactory_p.h>
|
||||
|
||||
#include "QtGui/qx11info_x11.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QX11PaintEngine;
|
||||
|
||||
struct QXImageWrapper;
|
||||
|
||||
class Q_WIDGETS_EXPORT QX11PlatformPixmap : public QPlatformPixmap
|
||||
{
|
||||
public:
|
||||
QX11PlatformPixmap(PixelType type);
|
||||
// QX11PlatformPixmap(PixelType type, int width, int height);
|
||||
// QX11PlatformPixmap(PixelType type, const QImage &image,
|
||||
// Qt::ImageConversionFlags flags);
|
||||
~QX11PlatformPixmap();
|
||||
|
||||
QPlatformPixmap *createCompatiblePlatformPixmap() const;
|
||||
|
||||
void resize(int width, int height);
|
||||
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
|
||||
void copy(const QPlatformPixmap *data, const QRect &rect);
|
||||
bool scroll(int dx, int dy, const QRect &rect);
|
||||
|
||||
void fill(const QColor &color);
|
||||
QBitmap mask() const;
|
||||
void setMask(const QBitmap &mask);
|
||||
bool hasAlphaChannel() const;
|
||||
void setAlphaChannel(const QPixmap &alphaChannel);
|
||||
QPixmap alphaChannel() const;
|
||||
QPixmap transformed(const QTransform &transform,
|
||||
Qt::TransformationMode mode) const;
|
||||
QImage toImage() const;
|
||||
QImage toImage(const QRect &rect) const;
|
||||
QPaintEngine* paintEngine() const;
|
||||
|
||||
Qt::HANDLE handle() const { return hd; }
|
||||
Qt::HANDLE x11ConvertToDefaultDepth();
|
||||
|
||||
static Qt::HANDLE createBitmapFromImage(const QImage &image);
|
||||
|
||||
void* gl_surface;
|
||||
#ifndef QT_NO_XRENDER
|
||||
void convertToARGB32(bool preserveContents = true);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||
|
||||
private:
|
||||
friend class QPixmap;
|
||||
friend class QBitmap;
|
||||
friend class QX11PaintEngine;
|
||||
friend class QX11WindowSurface;
|
||||
friend class QRasterWindowSurface;
|
||||
friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags
|
||||
friend class QEglContext; // Needs gl_surface
|
||||
friend class QGLContext; // Needs gl_surface
|
||||
friend class QX11GLPlatformPixmap; // Needs gl_surface
|
||||
friend class QMeeGoLivePlatformPixmap; // Needs gl_surface and flags
|
||||
friend bool qt_createEGLSurfaceForPixmap(QPlatformPixmap*, bool); // Needs gl_surface
|
||||
|
||||
void release();
|
||||
|
||||
QImage toImage(const QXImageWrapper &xi, const QRect &rect) const;
|
||||
|
||||
QBitmap mask_to_bitmap(int screen) const;
|
||||
static Qt::HANDLE bitmap_to_mask(const QBitmap &, int screen);
|
||||
void bitmapFromImage(const QImage &image);
|
||||
|
||||
bool canTakeQImageFromXImage(const QXImageWrapper &xi) const;
|
||||
QImage takeQImageFromXImage(const QXImageWrapper &xi) const;
|
||||
|
||||
Qt::HANDLE hd;
|
||||
|
||||
enum Flag {
|
||||
NoFlags = 0x0,
|
||||
Uninitialized = 0x1,
|
||||
Readonly = 0x2,
|
||||
InvertedWhenBoundToTexture = 0x4,
|
||||
GlSurfaceCreatedWithAlpha = 0x8
|
||||
};
|
||||
uint flags;
|
||||
|
||||
QX11Info xinfo;
|
||||
Qt::HANDLE x11_mask;
|
||||
Qt::HANDLE picture;
|
||||
Qt::HANDLE mask_picture;
|
||||
Qt::HANDLE hd2; // sorted in the default display depth
|
||||
QPixmap::ShareMode share_mode;
|
||||
|
||||
QX11PaintEngine *pengine;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPIXMAPDATA_X11_P_H
|
||||
|
@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qt_x11_p.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0};
|
||||
|
||||
void QRegion::updateX11Region() const
|
||||
{
|
||||
d->rgn = XCreateRegion();
|
||||
if (!d->qt_rgn)
|
||||
return;
|
||||
|
||||
int n = d->qt_rgn->numRects;
|
||||
const QRect *rect = (n == 1 ? &d->qt_rgn->extents : d->qt_rgn->rects.constData());
|
||||
while (n--) {
|
||||
XRectangle r;
|
||||
r.x = qMax(SHRT_MIN, rect->x());
|
||||
r.y = qMax(SHRT_MIN, rect->y());
|
||||
r.width = qMin((int)USHRT_MAX, rect->width());
|
||||
r.height = qMin((int)USHRT_MAX, rect->height());
|
||||
XUnionRectWithRegion(&r, d->rgn, d->rgn);
|
||||
++rect;
|
||||
}
|
||||
}
|
||||
|
||||
void *QRegion::clipRectangles(int &num) const
|
||||
{
|
||||
if (!d->xrectangles && !(d == &shared_empty || d->qt_rgn->numRects == 0)) {
|
||||
XRectangle *r = static_cast<XRectangle*>(malloc(d->qt_rgn->numRects * sizeof(XRectangle)));
|
||||
d->xrectangles = r;
|
||||
int n = d->qt_rgn->numRects;
|
||||
const QRect *rect = (n == 1 ? &d->qt_rgn->extents : d->qt_rgn->rects.constData());
|
||||
while (n--) {
|
||||
r->x = qMax(SHRT_MIN, rect->x());
|
||||
r->y = qMax(SHRT_MIN, rect->y());
|
||||
r->width = qMin((int)USHRT_MAX, rect->width());
|
||||
r->height = qMin((int)USHRT_MAX, rect->height());
|
||||
++r;
|
||||
++rect;
|
||||
}
|
||||
}
|
||||
if (d == &shared_empty || d->qt_rgn->numRects == 0)
|
||||
num = 0;
|
||||
else
|
||||
num = d->qt_rgn->numRects;
|
||||
return d->xrectangles;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,296 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qsound.h"
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
#include "qhash.h"
|
||||
#include "qsocketnotifier.h"
|
||||
#include "qapplication.h"
|
||||
#include "qsound_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_NAS
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include <audio/audiolib.h>
|
||||
#include <audio/soundlib.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
static AuServer *nas=0;
|
||||
|
||||
static AuBool eventPred(AuServer *, AuEvent *e, AuPointer p)
|
||||
{
|
||||
if (e && (e->type == AuEventTypeElementNotify)) {
|
||||
if (e->auelementnotify.flow == *((AuFlowID *)p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class QAuBucketNAS : public QAuBucket {
|
||||
public:
|
||||
QAuBucketNAS(AuBucketID b, AuFlowID f = 0) : id(b), flow(f), stopped(true), numplaying(0) { }
|
||||
~QAuBucketNAS()
|
||||
{
|
||||
if (nas) {
|
||||
AuSync(nas, false);
|
||||
AuDestroyBucket(nas, id, NULL);
|
||||
|
||||
AuEvent ev;
|
||||
while (AuScanEvents(nas, AuEventsQueuedAfterFlush, true, eventPred, &flow, &ev))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
AuBucketID id;
|
||||
AuFlowID flow;
|
||||
bool stopped;
|
||||
int numplaying;
|
||||
};
|
||||
|
||||
class QAuServerNAS : public QAuServer {
|
||||
Q_OBJECT
|
||||
|
||||
QSocketNotifier* sn;
|
||||
|
||||
public:
|
||||
QAuServerNAS(QObject* parent);
|
||||
~QAuServerNAS();
|
||||
|
||||
void init(QSound*);
|
||||
void play(const QString& filename);
|
||||
void play(QSound*);
|
||||
void stop(QSound*);
|
||||
bool okay();
|
||||
void setDone(QSound*);
|
||||
|
||||
public slots:
|
||||
void dataReceived();
|
||||
void soundDestroyed(QObject *o);
|
||||
|
||||
private:
|
||||
QAuBucketNAS* bucket(QSound* s)
|
||||
{
|
||||
return (QAuBucketNAS*)QAuServer::bucket(s);
|
||||
}
|
||||
};
|
||||
|
||||
QAuServerNAS::QAuServerNAS(QObject* parent) :
|
||||
QAuServer(parent)
|
||||
{
|
||||
setObjectName(QLatin1String("Network Audio System"));
|
||||
nas = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
|
||||
if (nas) {
|
||||
AuSetCloseDownMode(nas, AuCloseDownDestroy, NULL);
|
||||
// Ask Qt for async messages...
|
||||
sn=new QSocketNotifier(AuServerConnectionNumber(nas),
|
||||
QSocketNotifier::Read);
|
||||
QObject::connect(sn, SIGNAL(activated(int)),
|
||||
this, SLOT(dataReceived()));
|
||||
} else {
|
||||
sn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QAuServerNAS::~QAuServerNAS()
|
||||
{
|
||||
if (nas)
|
||||
AuCloseServer(nas);
|
||||
delete sn;
|
||||
nas = 0;
|
||||
}
|
||||
|
||||
typedef QHash<void*,QAuServerNAS*> AuServerHash;
|
||||
static AuServerHash *inprogress=0;
|
||||
|
||||
void QAuServerNAS::soundDestroyed(QObject *o)
|
||||
{
|
||||
if (inprogress) {
|
||||
QSound *so = static_cast<QSound *>(o);
|
||||
while (inprogress->remove(so))
|
||||
; // Loop while remove returns true
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServerNAS::play(const QString& filename)
|
||||
{
|
||||
if (nas) {
|
||||
int iv=100;
|
||||
AuFixedPoint volume=AuFixedPointFromFraction(iv,100);
|
||||
AuSoundPlayFromFile(nas, filename.toLocal8Bit().constData(), AuNone, volume,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
AuFlush(nas);
|
||||
dataReceived();
|
||||
AuFlush(nas);
|
||||
qApp->flush();
|
||||
}
|
||||
}
|
||||
|
||||
static void callback(AuServer*, AuEventHandlerRec*, AuEvent* e, AuPointer p)
|
||||
{
|
||||
if (inprogress->contains(p) && e) {
|
||||
if (e->type==AuEventTypeElementNotify &&
|
||||
e->auelementnotify.kind==AuElementNotifyKindState) {
|
||||
if (e->auelementnotify.cur_state == AuStateStop) {
|
||||
AuServerHash::Iterator it = inprogress->find(p);
|
||||
if (it != inprogress->end())
|
||||
(*it)->setDone((QSound*)p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServerNAS::setDone(QSound* s)
|
||||
{
|
||||
if (nas) {
|
||||
decLoop(s);
|
||||
if (s->loopsRemaining() && !bucket(s)->stopped) {
|
||||
bucket(s)->stopped = true;
|
||||
play(s);
|
||||
} else {
|
||||
if (--(bucket(s)->numplaying) == 0)
|
||||
bucket(s)->stopped = true;
|
||||
inprogress->remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServerNAS::play(QSound* s)
|
||||
{
|
||||
if (nas) {
|
||||
++(bucket(s)->numplaying);
|
||||
if (!bucket(s)->stopped) {
|
||||
stop(s);
|
||||
}
|
||||
|
||||
bucket(s)->stopped = false;
|
||||
if (!inprogress)
|
||||
inprogress = new AuServerHash;
|
||||
inprogress->insert(s,this);
|
||||
int iv=100;
|
||||
AuFixedPoint volume=AuFixedPointFromFraction(iv,100);
|
||||
QAuBucketNAS *b = bucket(s);
|
||||
AuSoundPlayFromBucket(nas, b->id, AuNone, volume,
|
||||
callback, s, 0, &b->flow, NULL, NULL, NULL);
|
||||
AuFlush(nas);
|
||||
dataReceived();
|
||||
AuFlush(nas);
|
||||
qApp->flush();
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServerNAS::stop(QSound* s)
|
||||
{
|
||||
if (nas && !bucket(s)->stopped) {
|
||||
bucket(s)->stopped = true;
|
||||
AuStopFlow(nas, bucket(s)->flow, NULL);
|
||||
AuFlush(nas);
|
||||
dataReceived();
|
||||
AuFlush(nas);
|
||||
qApp->flush();
|
||||
}
|
||||
}
|
||||
|
||||
void QAuServerNAS::init(QSound* s)
|
||||
{
|
||||
connect(s, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(soundDestroyed(QObject*)));
|
||||
|
||||
if (nas) {
|
||||
AuBucketID b_id =
|
||||
AuSoundCreateBucketFromFile(nas, s->fileName().toLocal8Bit().constData(),
|
||||
0 /*AuAccessAllMasks*/, NULL, NULL);
|
||||
setBucket(s, new QAuBucketNAS(b_id));
|
||||
}
|
||||
}
|
||||
|
||||
bool QAuServerNAS::okay()
|
||||
{
|
||||
return !!nas;
|
||||
}
|
||||
|
||||
void QAuServerNAS::dataReceived()
|
||||
{
|
||||
AuHandleEvents(nas);
|
||||
}
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include "qsound_x11.moc"
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class QAuServerNull : public QAuServer
|
||||
{
|
||||
public:
|
||||
QAuServerNull(QObject* parent);
|
||||
|
||||
void play(const QString&) { }
|
||||
void play(QSound*s) { while(decLoop(s) > 0) /* nothing */ ; }
|
||||
void stop(QSound*) { }
|
||||
bool okay() { return false; }
|
||||
};
|
||||
|
||||
QAuServerNull::QAuServerNull(QObject* parent)
|
||||
: QAuServer(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QAuServer* qt_new_audio_server()
|
||||
{
|
||||
#ifndef QT_NO_NAS
|
||||
QAuServer* s = new QAuServerNAS(qApp);
|
||||
if (s->okay())
|
||||
return s;
|
||||
else
|
||||
delete s;
|
||||
#endif
|
||||
return new QAuServerNull(qApp);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_SOUND
|
@ -1,757 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_X11_P_H
|
||||
#define QT_X11_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtGui/qwindowdefs.h"
|
||||
#include "QtCore/qlist.h"
|
||||
#include "QtCore/qvariant.h"
|
||||
|
||||
// the following is necessary to work around breakage in many versions
|
||||
// of XFree86's Xlib.h still in use
|
||||
// ### which versions?
|
||||
#if defined(_XLIB_H_) // crude hack, but...
|
||||
#error "cannot include <X11/Xlib.h> before this file"
|
||||
#endif
|
||||
#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
|
||||
#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
|
||||
#define XSetIMValues qt_XSetIMValues
|
||||
#include <X11/Xlib.h>
|
||||
#undef XRegisterIMInstantiateCallback
|
||||
#undef XUnregisterIMInstantiateCallback
|
||||
#undef XSetIMValues
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xos.h>
|
||||
#ifdef index
|
||||
# undef index
|
||||
#endif
|
||||
#ifdef rindex
|
||||
# undef rindex
|
||||
#endif
|
||||
#ifdef Q_OS_VXWORS
|
||||
# ifdef open
|
||||
# undef open
|
||||
# endif
|
||||
# ifdef getpid
|
||||
# undef getpid
|
||||
# endif
|
||||
#endif // Q_OS_VXWORKS
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
//#define QT_NO_SHAPE
|
||||
#ifdef QT_NO_SHAPE
|
||||
# define XShapeCombineRegion(a,b,c,d,e,f,g)
|
||||
# define XShapeCombineMask(a,b,c,d,e,f,g)
|
||||
#else
|
||||
# include <X11/extensions/shape.h>
|
||||
#endif // QT_NO_SHAPE
|
||||
|
||||
|
||||
#if !defined (QT_NO_TABLET)
|
||||
# include <X11/extensions/XInput.h>
|
||||
#if defined (Q_OS_IRIX)
|
||||
# include <X11/extensions/SGIMisc.h>
|
||||
# include <wacom.h>
|
||||
#endif
|
||||
#endif // QT_NO_TABLET
|
||||
|
||||
|
||||
// #define QT_NO_XINERAMA
|
||||
#ifndef QT_NO_XINERAMA
|
||||
# if 0 // ### Xsun, but how to detect it?
|
||||
// Xinerama is only supported in Solaris 7 with patches 107648/108376 and
|
||||
// Solaris 8 or above which introduce the X11R6.4 Xserver.
|
||||
// To switch the Xinerama functionality on, you need to add the "+xinerama"
|
||||
// argument to the Xsun start line.
|
||||
// At least Solaris 7 and 8 are missing Xinerama system headers and function
|
||||
// declarations (bug 4284701).
|
||||
// The Xinerama API is not documented. In theory it could change but it
|
||||
// probably won't because Sun are using it in at least dtlogin (bug 4221829).
|
||||
extern "C" Bool XPanoramiXQueryExtension(
|
||||
Display*,
|
||||
int*,
|
||||
int*
|
||||
);
|
||||
extern "C" Status XPanoramiXQueryVersion(
|
||||
Display*,
|
||||
int*,
|
||||
int*
|
||||
);
|
||||
extern "C" Status XPanoramiXGetState(
|
||||
Display*,
|
||||
Drawable,
|
||||
XPanoramiXInfo*
|
||||
);
|
||||
extern "C" Status XPanoramiXGetScreenCount(
|
||||
Display *,
|
||||
Drawable,
|
||||
XPanoramiXInfo*
|
||||
);
|
||||
extern "C" Status XPanoramiXGetScreenSize(
|
||||
Display*,
|
||||
Drawable,
|
||||
int,
|
||||
XPanoramiXInfo*
|
||||
);
|
||||
# else // XFree86
|
||||
// XFree86 does not C++ify Xinerama (at least up to XFree86 4.0.3).
|
||||
extern "C" {
|
||||
# include <X11/extensions/Xinerama.h>
|
||||
}
|
||||
# endif
|
||||
#endif // QT_NO_XINERAMA
|
||||
|
||||
// #define QT_NO_XRANDR
|
||||
#ifndef QT_NO_XRANDR
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif // QT_NO_XRANDR
|
||||
|
||||
// #define QT_NO_XRENDER
|
||||
#ifndef QT_NO_XRENDER
|
||||
# include <X11/extensions/Xrender.h>
|
||||
#endif // QT_NO_XRENDER
|
||||
|
||||
#ifndef QT_NO_XSYNC
|
||||
extern "C" {
|
||||
# include "X11/extensions/sync.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
// #define QT_NO_XKB
|
||||
#ifndef QT_NO_XKB
|
||||
# include <X11/XKBlib.h>
|
||||
#endif // QT_NO_XKB
|
||||
|
||||
|
||||
#if !defined(XlibSpecificationRelease)
|
||||
# define X11R4
|
||||
typedef char *XPointer;
|
||||
#else
|
||||
# undef X11R4
|
||||
#endif
|
||||
|
||||
// #define QT_NO_XIM
|
||||
#if defined(X11R4)
|
||||
// X11R4 does not have XIM
|
||||
#define QT_NO_XIM
|
||||
#elif defined(Q_OS_OSF) && (XlibSpecificationRelease < 6)
|
||||
// broken in Xlib up to OSF/1 3.2
|
||||
#define QT_NO_XIM
|
||||
#elif defined(Q_OS_AIX)
|
||||
// broken in Xlib up to what version of AIX?
|
||||
#define QT_NO_XIM
|
||||
#elif defined(QT_NO_DEBUG) && defined(Q_OS_IRIX)
|
||||
// XmbLookupString broken on IRIX
|
||||
// XCreateIC broken when compiling -64 on IRIX 6.5.2
|
||||
#define QT_NO_XIM
|
||||
#elif defined(Q_OS_HPUX) && defined(__LP64__)
|
||||
// XCreateIC broken when compiling 64-bit ELF on HP-UX 11.0
|
||||
#define QT_NO_XIM
|
||||
#elif defined(Q_OS_SCO)
|
||||
// ### suggested by user...
|
||||
// ### #define QT_NO_XIM
|
||||
#endif // QT_NO_XIM
|
||||
|
||||
#ifndef QT_NO_XFIXES
|
||||
typedef Bool (*PtrXFixesQueryExtension)(Display *, int *, int *);
|
||||
typedef Status (*PtrXFixesQueryVersion)(Display *, int *, int *);
|
||||
typedef void (*PtrXFixesSetCursorName)(Display *dpy, Cursor cursor, const char *name);
|
||||
typedef void (*PtrXFixesSelectSelectionInput)(Display *dpy, Window win, Atom selection, unsigned long eventMask);
|
||||
#endif // QT_NO_XFIXES
|
||||
|
||||
#ifndef QT_NO_XCURSOR
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
typedef Cursor (*PtrXcursorLibraryLoadCursor)(Display *, const char *);
|
||||
#endif // QT_NO_XCURSOR
|
||||
|
||||
#ifndef QT_NO_XINERAMA
|
||||
typedef Bool (*PtrXineramaQueryExtension)(Display *dpy, int *event_base, int *error_base);
|
||||
typedef Bool (*PtrXineramaIsActive)(Display *dpy);
|
||||
typedef XineramaScreenInfo *(*PtrXineramaQueryScreens)(Display *dpy, int *number);
|
||||
#endif // QT_NO_XINERAMA
|
||||
|
||||
#ifndef QT_NO_XRANDR
|
||||
typedef void (*PtrXRRSelectInput)(Display *, Window, int);
|
||||
typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
|
||||
typedef int (*PtrXRRRootToScreen)(Display *, Window);
|
||||
typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
|
||||
typedef XRRScreenSize *(*PtrXRRSizes)(Display *, int, int *);
|
||||
#endif // QT_NO_XRANDR
|
||||
|
||||
#ifndef QT_NO_XINPUT
|
||||
typedef int (*PtrXCloseDevice)(Display *, XDevice *);
|
||||
typedef XDeviceInfo* (*PtrXListInputDevices)(Display *, int *);
|
||||
typedef XDevice* (*PtrXOpenDevice)(Display *, XID);
|
||||
typedef void (*PtrXFreeDeviceList)(XDeviceInfo *);
|
||||
typedef int (*PtrXSelectExtensionEvent)(Display *, Window, XEventClass *, int);
|
||||
#endif // QT_NO_XINPUT
|
||||
|
||||
/*
|
||||
* Solaris patch 108652-47 and higher fixes crases in
|
||||
* XRegisterIMInstantiateCallback, but the function doesn't seem to
|
||||
* work.
|
||||
*
|
||||
* Instead, we disabled R6 input, and open the input method
|
||||
* immediately at application start.
|
||||
*/
|
||||
#if !defined(QT_NO_XIM) && (XlibSpecificationRelease >= 6) && \
|
||||
!defined(Q_OS_SOLARIS)
|
||||
#define USE_X11R6_XIM
|
||||
|
||||
//######### XFree86 has wrong declarations for XRegisterIMInstantiateCallback
|
||||
//######### and XUnregisterIMInstantiateCallback in at least version 3.3.2.
|
||||
//######### Many old X11R6 header files lack XSetIMValues.
|
||||
//######### Therefore, we have to declare these functions ourselves.
|
||||
|
||||
extern "C" Bool XRegisterIMInstantiateCallback(
|
||||
Display*,
|
||||
struct _XrmHashBucketRec*,
|
||||
char*,
|
||||
char*,
|
||||
XIMProc, //XFree86 has XIDProc, which has to be wrong
|
||||
XPointer
|
||||
);
|
||||
|
||||
extern "C" Bool XUnregisterIMInstantiateCallback(
|
||||
Display*,
|
||||
struct _XrmHashBucketRec*,
|
||||
char*,
|
||||
char*,
|
||||
XIMProc, //XFree86 has XIDProc, which has to be wrong
|
||||
XPointer
|
||||
);
|
||||
|
||||
extern "C" char *XSetIMValues(XIM /* im */, ...);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_FONTCONFIG
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_XIM
|
||||
// some platforms (eg. Solaris 2.51) don't have these defines in Xlib.h
|
||||
#ifndef XNResetState
|
||||
#define XNResetState "resetState"
|
||||
#endif
|
||||
#ifndef XIMPreserveState
|
||||
#define XIMPreserveState (1L<<1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef X11R4
|
||||
# include <X11/Xlocale.h>
|
||||
#endif // X11R4
|
||||
|
||||
|
||||
#ifndef QT_NO_MITSHM
|
||||
# include <X11/extensions/XShm.h>
|
||||
#endif // QT_NO_MITSHM
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidget;
|
||||
|
||||
struct QX11InfoData {
|
||||
uint ref;
|
||||
int screen;
|
||||
int dpiX;
|
||||
int dpiY;
|
||||
int depth;
|
||||
int cells;
|
||||
Colormap colormap;
|
||||
Visual *visual;
|
||||
bool defaultColormap;
|
||||
bool defaultVisual;
|
||||
int subpixel;
|
||||
};
|
||||
|
||||
class QDrag;
|
||||
struct QXdndDropTransaction
|
||||
{
|
||||
Time timestamp;
|
||||
Window target;
|
||||
Window proxy_target;
|
||||
QWidget *targetWidget;
|
||||
QWidget *embedding_widget;
|
||||
QDrag *object;
|
||||
};
|
||||
|
||||
class QMimeData;
|
||||
|
||||
struct QX11Data;
|
||||
extern Q_WIDGETS_EXPORT QX11Data *qt_x11Data;
|
||||
|
||||
enum DesktopEnvironment {
|
||||
DE_UNKNOWN,
|
||||
DE_KDE,
|
||||
DE_GNOME,
|
||||
DE_CDE,
|
||||
DE_MEEGO_COMPOSITOR,
|
||||
DE_4DWM
|
||||
};
|
||||
|
||||
struct QX11Data
|
||||
{
|
||||
static Qt::KeyboardModifiers translateModifiers(int s);
|
||||
|
||||
Window findClientWindow(Window, Atom, bool);
|
||||
|
||||
// from qclipboard_x11.cpp
|
||||
bool clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout);
|
||||
bool clipboardReadProperty(Window win, Atom property, bool deleteProperty,
|
||||
QByteArray *buffer, int *size, Atom *type, int *format);
|
||||
QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm);
|
||||
|
||||
// from qdnd_x11.cpp
|
||||
bool dndEnable(QWidget* w, bool on);
|
||||
static void xdndSetup();
|
||||
void xdndHandleEnter(QWidget *, const XEvent *, bool);
|
||||
void xdndHandlePosition(QWidget *, const XEvent *, bool);
|
||||
void xdndHandleStatus(QWidget *, const XEvent *, bool);
|
||||
void xdndHandleLeave(QWidget *, const XEvent *, bool);
|
||||
void xdndHandleDrop(QWidget *, const XEvent *, bool);
|
||||
void xdndHandleFinished(QWidget *, const XEvent *, bool);
|
||||
void xdndHandleSelectionRequest(const XSelectionRequestEvent *);
|
||||
static bool xdndHandleBadwindow();
|
||||
QByteArray xdndAtomToString(Atom a);
|
||||
Atom xdndStringToAtom(const char *);
|
||||
|
||||
QString xdndMimeAtomToString(Atom a);
|
||||
Atom xdndMimeStringToAtom(const QString &mimeType);
|
||||
QStringList xdndMimeFormatsForAtom(Atom a);
|
||||
bool xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat);
|
||||
QList<Atom> xdndMimeAtomsForFormat(const QString &format);
|
||||
QVariant xdndMimeConvertToFormat(Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding);
|
||||
Atom xdndMimeAtomForFormat(const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding);
|
||||
|
||||
QList<QXdndDropTransaction> dndDropTransactions;
|
||||
|
||||
// from qmotifdnd_x11.cpp
|
||||
void motifdndHandle(QWidget *, const XEvent *, bool);
|
||||
void motifdndEnable(QWidget *, bool);
|
||||
QVariant motifdndObtainData(const char *format);
|
||||
QByteArray motifdndFormat(int n);
|
||||
bool motifdnd_active;
|
||||
|
||||
Display *display;
|
||||
char *displayName;
|
||||
bool foreignDisplay;
|
||||
// current focus model
|
||||
enum {
|
||||
FM_Unknown = -1,
|
||||
FM_Other = 0,
|
||||
FM_PointerRoot = 1
|
||||
};
|
||||
int focus_model;
|
||||
|
||||
// true if Qt is compiled w/ RANDR support and RANDR is supported on the connected Display
|
||||
bool use_xrandr;
|
||||
int xrandr_major;
|
||||
int xrandr_eventbase;
|
||||
int xrandr_errorbase;
|
||||
|
||||
// true if Qt is compiled w/ RENDER support and RENDER is supported on the connected Display
|
||||
bool use_xrender;
|
||||
int xrender_major;
|
||||
int xrender_version;
|
||||
|
||||
// true if Qt is compiled w/ XFIXES support and XFIXES is supported on the connected Display
|
||||
bool use_xfixes;
|
||||
int xfixes_major;
|
||||
int xfixes_eventbase;
|
||||
int xfixes_errorbase;
|
||||
|
||||
#ifndef QT_NO_XFIXES
|
||||
PtrXFixesQueryExtension ptrXFixesQueryExtension;
|
||||
PtrXFixesQueryVersion ptrXFixesQueryVersion;
|
||||
PtrXFixesSetCursorName ptrXFixesSetCursorName;
|
||||
PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput;
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_XINPUT
|
||||
PtrXCloseDevice ptrXCloseDevice;
|
||||
PtrXListInputDevices ptrXListInputDevices;
|
||||
PtrXOpenDevice ptrXOpenDevice;
|
||||
PtrXFreeDeviceList ptrXFreeDeviceList;
|
||||
PtrXSelectExtensionEvent ptrXSelectExtensionEvent;
|
||||
#endif // QT_NO_XINPUT
|
||||
|
||||
|
||||
// true if Qt is compiled w/ MIT-SHM support and MIT-SHM is supported on the connected Display
|
||||
bool use_mitshm;
|
||||
bool use_mitshm_pixmaps;
|
||||
int mitshm_major;
|
||||
|
||||
// true if Qt is compiled w/ Tablet support and we have a tablet.
|
||||
bool use_xinput;
|
||||
int xinput_major;
|
||||
int xinput_eventbase;
|
||||
int xinput_errorbase;
|
||||
|
||||
// for XKEYBOARD support
|
||||
bool use_xkb;
|
||||
int xkb_major;
|
||||
int xkb_eventbase;
|
||||
int xkb_errorbase;
|
||||
|
||||
QList<QWidget *> deferred_map;
|
||||
struct ScrollInProgress {
|
||||
long id;
|
||||
QWidget* scrolled_widget;
|
||||
int dx, dy;
|
||||
};
|
||||
long sip_serial;
|
||||
QList<ScrollInProgress> sip_list;
|
||||
|
||||
// window managers list of supported "stuff"
|
||||
Atom *net_supported_list;
|
||||
// list of virtual root windows
|
||||
Window *net_virtual_root_list;
|
||||
// client leader window
|
||||
Window wm_client_leader;
|
||||
|
||||
QX11InfoData *screens;
|
||||
Visual **argbVisuals;
|
||||
Colormap *argbColormaps;
|
||||
int screenCount;
|
||||
int defaultScreen;
|
||||
|
||||
Time time;
|
||||
Time userTime;
|
||||
|
||||
QString default_im;
|
||||
|
||||
// starts to ignore bad window errors from X
|
||||
static inline void ignoreBadwindow() {
|
||||
qt_x11Data->ignore_badwindow = true;
|
||||
qt_x11Data->seen_badwindow = false;
|
||||
}
|
||||
|
||||
// ends ignoring bad window errors and returns whether an error had happened.
|
||||
static inline bool badwindow() {
|
||||
qt_x11Data->ignore_badwindow = false;
|
||||
return qt_x11Data->seen_badwindow;
|
||||
}
|
||||
|
||||
bool ignore_badwindow;
|
||||
bool seen_badwindow;
|
||||
|
||||
// options
|
||||
int visual_class;
|
||||
int visual_id;
|
||||
int color_count;
|
||||
bool custom_cmap;
|
||||
|
||||
// outside visual/colormap
|
||||
Visual *visual;
|
||||
Colormap colormap;
|
||||
|
||||
#ifndef QT_NO_XRENDER
|
||||
enum { solid_fill_count = 16 };
|
||||
struct SolidFills {
|
||||
XRenderColor color;
|
||||
int screen;
|
||||
Picture picture;
|
||||
} solid_fills[solid_fill_count];
|
||||
enum { pattern_fill_count = 16 };
|
||||
struct PatternFills {
|
||||
XRenderColor color;
|
||||
XRenderColor bg_color;
|
||||
int screen;
|
||||
int style;
|
||||
bool opaque;
|
||||
Picture picture;
|
||||
} pattern_fills[pattern_fill_count];
|
||||
Picture getSolidFill(int screen, const QColor &c);
|
||||
XRenderColor preMultiply(const QColor &c);
|
||||
#endif
|
||||
|
||||
bool has_fontconfig;
|
||||
qreal fc_scale;
|
||||
bool fc_antialias;
|
||||
int fc_hint_style;
|
||||
|
||||
char *startupId;
|
||||
|
||||
DesktopEnvironment desktopEnvironment : 8;
|
||||
uint desktopVersion : 8; /* Used only for KDE */
|
||||
|
||||
/* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */
|
||||
enum X11Atom {
|
||||
// window-manager <-> client protocols
|
||||
WM_PROTOCOLS,
|
||||
WM_DELETE_WINDOW,
|
||||
WM_TAKE_FOCUS,
|
||||
_NET_WM_PING,
|
||||
_NET_WM_CONTEXT_HELP,
|
||||
_NET_WM_SYNC_REQUEST,
|
||||
_NET_WM_SYNC_REQUEST_COUNTER,
|
||||
|
||||
// ICCCM window state
|
||||
WM_STATE,
|
||||
WM_CHANGE_STATE,
|
||||
|
||||
// Session management
|
||||
WM_CLIENT_LEADER,
|
||||
WM_WINDOW_ROLE,
|
||||
SM_CLIENT_ID,
|
||||
|
||||
// Clipboard
|
||||
CLIPBOARD,
|
||||
INCR,
|
||||
TARGETS,
|
||||
MULTIPLE,
|
||||
TIMESTAMP,
|
||||
SAVE_TARGETS,
|
||||
CLIP_TEMPORARY,
|
||||
_QT_SELECTION,
|
||||
_QT_CLIPBOARD_SENTINEL,
|
||||
_QT_SELECTION_SENTINEL,
|
||||
CLIPBOARD_MANAGER,
|
||||
|
||||
RESOURCE_MANAGER,
|
||||
|
||||
_XSETROOT_ID,
|
||||
|
||||
_QT_SCROLL_DONE,
|
||||
_QT_INPUT_ENCODING,
|
||||
|
||||
_MOTIF_WM_HINTS,
|
||||
|
||||
DTWM_IS_RUNNING,
|
||||
ENLIGHTENMENT_DESKTOP,
|
||||
_DT_SAVE_MODE,
|
||||
_SGI_DESKS_MANAGER,
|
||||
|
||||
// EWMH (aka NETWM)
|
||||
_NET_SUPPORTED,
|
||||
_NET_VIRTUAL_ROOTS,
|
||||
_NET_WORKAREA,
|
||||
|
||||
_NET_MOVERESIZE_WINDOW,
|
||||
_NET_WM_MOVERESIZE,
|
||||
|
||||
_NET_WM_NAME,
|
||||
_NET_WM_ICON_NAME,
|
||||
_NET_WM_ICON,
|
||||
|
||||
_NET_WM_PID,
|
||||
|
||||
_NET_WM_WINDOW_OPACITY,
|
||||
|
||||
_NET_WM_STATE,
|
||||
_NET_WM_STATE_ABOVE,
|
||||
_NET_WM_STATE_BELOW,
|
||||
_NET_WM_STATE_FULLSCREEN,
|
||||
_NET_WM_STATE_MAXIMIZED_HORZ,
|
||||
_NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_NET_WM_STATE_MODAL,
|
||||
_NET_WM_STATE_STAYS_ON_TOP,
|
||||
_NET_WM_STATE_DEMANDS_ATTENTION,
|
||||
|
||||
_NET_WM_USER_TIME,
|
||||
_NET_WM_USER_TIME_WINDOW,
|
||||
_NET_WM_FULL_PLACEMENT,
|
||||
|
||||
_NET_WM_WINDOW_TYPE,
|
||||
_NET_WM_WINDOW_TYPE_DESKTOP,
|
||||
_NET_WM_WINDOW_TYPE_DOCK,
|
||||
_NET_WM_WINDOW_TYPE_TOOLBAR,
|
||||
_NET_WM_WINDOW_TYPE_MENU,
|
||||
_NET_WM_WINDOW_TYPE_UTILITY,
|
||||
_NET_WM_WINDOW_TYPE_SPLASH,
|
||||
_NET_WM_WINDOW_TYPE_DIALOG,
|
||||
_NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
|
||||
_NET_WM_WINDOW_TYPE_POPUP_MENU,
|
||||
_NET_WM_WINDOW_TYPE_TOOLTIP,
|
||||
_NET_WM_WINDOW_TYPE_NOTIFICATION,
|
||||
_NET_WM_WINDOW_TYPE_COMBO,
|
||||
_NET_WM_WINDOW_TYPE_DND,
|
||||
_NET_WM_WINDOW_TYPE_NORMAL,
|
||||
_KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
|
||||
|
||||
_KDE_NET_WM_FRAME_STRUT,
|
||||
|
||||
_NET_STARTUP_INFO,
|
||||
_NET_STARTUP_INFO_BEGIN,
|
||||
|
||||
_NET_SUPPORTING_WM_CHECK,
|
||||
|
||||
_NET_WM_CM_S0,
|
||||
|
||||
_NET_SYSTEM_TRAY_VISUAL,
|
||||
|
||||
_NET_ACTIVE_WINDOW,
|
||||
|
||||
// Property formats
|
||||
COMPOUND_TEXT,
|
||||
TEXT,
|
||||
UTF8_STRING,
|
||||
|
||||
// Xdnd
|
||||
XdndEnter,
|
||||
XdndPosition,
|
||||
XdndStatus,
|
||||
XdndLeave,
|
||||
XdndDrop,
|
||||
XdndFinished,
|
||||
XdndTypelist,
|
||||
XdndActionList,
|
||||
|
||||
XdndSelection,
|
||||
|
||||
XdndAware,
|
||||
XdndProxy,
|
||||
|
||||
XdndActionCopy,
|
||||
XdndActionLink,
|
||||
XdndActionMove,
|
||||
XdndActionPrivate,
|
||||
|
||||
// Motif DND
|
||||
_MOTIF_DRAG_AND_DROP_MESSAGE,
|
||||
_MOTIF_DRAG_INITIATOR_INFO,
|
||||
_MOTIF_DRAG_RECEIVER_INFO,
|
||||
_MOTIF_DRAG_WINDOW,
|
||||
_MOTIF_DRAG_TARGETS,
|
||||
|
||||
XmTRANSFER_SUCCESS,
|
||||
XmTRANSFER_FAILURE,
|
||||
|
||||
// Xkb
|
||||
_XKB_RULES_NAMES,
|
||||
|
||||
// XEMBED
|
||||
_XEMBED,
|
||||
_XEMBED_INFO,
|
||||
|
||||
XWacomStylus,
|
||||
XWacomCursor,
|
||||
XWacomEraser,
|
||||
|
||||
XTabletStylus,
|
||||
XTabletEraser,
|
||||
|
||||
NPredefinedAtoms,
|
||||
|
||||
_QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
|
||||
NAtoms
|
||||
};
|
||||
Atom atoms[NAtoms];
|
||||
|
||||
bool isSupportedByWM(Atom atom);
|
||||
|
||||
bool compositingManagerRunning;
|
||||
|
||||
#ifndef QT_NO_XCURSOR
|
||||
PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor;
|
||||
#endif // QT_NO_XCURSOR
|
||||
|
||||
#ifndef QT_NO_XINERAMA
|
||||
PtrXineramaQueryExtension ptrXineramaQueryExtension;
|
||||
PtrXineramaIsActive ptrXineramaIsActive;
|
||||
PtrXineramaQueryScreens ptrXineramaQueryScreens;
|
||||
#endif // QT_NO_XINERAMA
|
||||
|
||||
#ifndef QT_NO_XRANDR
|
||||
PtrXRRSelectInput ptrXRRSelectInput;
|
||||
PtrXRRUpdateConfiguration ptrXRRUpdateConfiguration;
|
||||
PtrXRRRootToScreen ptrXRRRootToScreen;
|
||||
PtrXRRQueryExtension ptrXRRQueryExtension;
|
||||
PtrXRRSizes ptrXRRSizes;
|
||||
#endif // QT_NO_XRANDR
|
||||
};
|
||||
|
||||
extern QX11Data *qt_x11Data;
|
||||
#define ATOM(x) qt_x11Data->atoms[QX11Data::x]
|
||||
#define X11 qt_x11Data
|
||||
|
||||
// rename a couple of X defines to get rid of name clashes
|
||||
// resolve the conflict between X11's FocusIn and QEvent::FocusIn
|
||||
enum {
|
||||
XFocusOut = FocusOut,
|
||||
XFocusIn = FocusIn,
|
||||
XKeyPress = KeyPress,
|
||||
XKeyRelease = KeyRelease,
|
||||
XNone = None,
|
||||
XRevertToParent = RevertToParent,
|
||||
XGrayScale = GrayScale,
|
||||
XCursorShape = CursorShape
|
||||
};
|
||||
#undef FocusOut
|
||||
#undef FocusIn
|
||||
#undef KeyPress
|
||||
#undef KeyRelease
|
||||
#undef None
|
||||
#undef RevertToParent
|
||||
#undef GrayScale
|
||||
#undef CursorShape
|
||||
|
||||
#ifdef FontChange
|
||||
#undef FontChange
|
||||
#endif
|
||||
|
||||
Q_DECLARE_TYPEINFO(XPoint, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(XRectangle, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(XChar2b, Q_PRIMITIVE_TYPE);
|
||||
#ifndef QT_NO_XRENDER
|
||||
Q_DECLARE_TYPEINFO(XGlyphElt32, Q_PRIMITIVE_TYPE);
|
||||
#endif
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_X11_P_H
|
File diff suppressed because it is too large
Load Diff
@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwidget.h"
|
||||
#include "qt_x11_p.h"
|
||||
|
||||
/*
|
||||
Internal Qt functions to create X windows. We have put them in
|
||||
separate functions to allow the programmer to reimplement them by
|
||||
custom versions.
|
||||
*/
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Window qt_XCreateWindow(const QWidget *, Display *display, Window parent,
|
||||
int x, int y, uint w, uint h,
|
||||
int borderwidth, int depth,
|
||||
uint windowclass, Visual *visual,
|
||||
ulong valuemask, XSetWindowAttributes *attributes)
|
||||
{
|
||||
return XCreateWindow(display, parent, x, y, w, h, borderwidth, depth,
|
||||
windowclass, visual, valuemask, attributes);
|
||||
}
|
||||
|
||||
|
||||
Window qt_XCreateSimpleWindow(const QWidget *, Display *display, Window parent,
|
||||
int x, int y, uint w, uint h, int borderwidth,
|
||||
ulong border, ulong background)
|
||||
{
|
||||
return XCreateSimpleWindow(display, parent, x, y, w, h, borderwidth,
|
||||
border, background);
|
||||
}
|
||||
|
||||
|
||||
void qt_XDestroyWindow(const QWidget *, Display *display, Window window)
|
||||
{
|
||||
if (window)
|
||||
XDestroyWindow(display, window);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,132 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QX11EMBED_X11_H
|
||||
#define QX11EMBED_X11_H
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QX11EmbedWidgetPrivate;
|
||||
class Q_WIDGETS_EXPORT QX11EmbedWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QX11EmbedWidget(QWidget *parent = 0);
|
||||
~QX11EmbedWidget();
|
||||
|
||||
void embedInto(WId id);
|
||||
WId containerWinId() const;
|
||||
|
||||
enum Error {
|
||||
Unknown,
|
||||
Internal,
|
||||
InvalidWindowID
|
||||
};
|
||||
Error error() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void embedded();
|
||||
void containerClosed();
|
||||
void error(QX11EmbedWidget::Error error);
|
||||
|
||||
protected:
|
||||
bool x11Event(XEvent *);
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
bool event(QEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QX11EmbedWidget)
|
||||
Q_DISABLE_COPY(QX11EmbedWidget)
|
||||
};
|
||||
|
||||
class QX11EmbedContainerPrivate;
|
||||
class Q_WIDGETS_EXPORT QX11EmbedContainer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QX11EmbedContainer(QWidget *parent = 0);
|
||||
~QX11EmbedContainer();
|
||||
|
||||
void embedClient(WId id);
|
||||
void discardClient();
|
||||
|
||||
WId clientWinId() const;
|
||||
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
enum Error {
|
||||
Unknown,
|
||||
Internal,
|
||||
InvalidWindowID
|
||||
};
|
||||
Error error() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void clientIsEmbedded();
|
||||
void clientClosed();
|
||||
void error(QX11EmbedContainer::Error);
|
||||
|
||||
protected:
|
||||
bool x11Event(XEvent *);
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void showEvent(QShowEvent *);
|
||||
void hideEvent(QHideEvent *);
|
||||
bool event(QEvent *);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QX11EmbedContainer)
|
||||
Q_DISABLE_COPY(QX11EmbedContainer)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QX11EMBED_X11_H
|
@ -1,544 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwidget.h"
|
||||
#include "qpixmap.h"
|
||||
#include "qx11info_x11.h"
|
||||
#include "qt_x11_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QX11Info
|
||||
\brief The QX11Info class provides information about the X display
|
||||
configuration.
|
||||
|
||||
\ingroup shared
|
||||
\inmodule QtWidgets
|
||||
|
||||
The class provides two APIs: a set of non-static functions that
|
||||
provide information about a specific widget or pixmap, and a set
|
||||
of static functions that provide the default information for the
|
||||
application.
|
||||
|
||||
\warning This class is only available on X11. For querying
|
||||
per-screen information in a portable way, use QDesktopWidget.
|
||||
|
||||
\sa QWidget::x11Info(), QPixmap::x11Info(), QDesktopWidget
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an empty QX11Info object.
|
||||
*/
|
||||
QX11Info::QX11Info()
|
||||
: x11data(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of \a other.
|
||||
*/
|
||||
QX11Info::QX11Info(const QX11Info &other)
|
||||
{
|
||||
x11data = other.x11data;
|
||||
if (x11data)
|
||||
++x11data->ref;
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns \a other to this object and returns a reference to this
|
||||
object.
|
||||
*/
|
||||
QX11Info &QX11Info::operator=(const QX11Info &other)
|
||||
{
|
||||
if (other.x11data)
|
||||
++other.x11data->ref;
|
||||
if (x11data && !--x11data->ref)
|
||||
delete x11data;
|
||||
x11data = other.x11data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QX11Info object.
|
||||
*/
|
||||
QX11Info::~QX11Info()
|
||||
{
|
||||
if (x11data && !--x11data->ref)
|
||||
delete x11data;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Makes a shallow copy of the X11-specific data of \a fromDevice, if it is not
|
||||
null. Otherwise this function sets it to null.
|
||||
*/
|
||||
|
||||
void QX11Info::copyX11Data(const QPaintDevice *fromDevice)
|
||||
{
|
||||
QX11InfoData *xd = 0;
|
||||
if (fromDevice) {
|
||||
if (fromDevice->devType() == QInternal::Widget)
|
||||
xd = static_cast<const QWidget *>(fromDevice)->x11Info().x11data;
|
||||
else if (fromDevice->devType() == QInternal::Pixmap)
|
||||
xd = static_cast<const QPixmap *>(fromDevice)->x11Info().x11data;
|
||||
}
|
||||
setX11Data(xd);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Makes a deep copy of the X11-specific data of \a fromDevice, if it is not
|
||||
null. Otherwise this function sets it to null.
|
||||
*/
|
||||
|
||||
void QX11Info::cloneX11Data(const QPaintDevice *fromDevice)
|
||||
{
|
||||
QX11InfoData *d = 0;
|
||||
if (fromDevice) {
|
||||
QX11InfoData *xd;
|
||||
if (fromDevice->devType() == QInternal::Widget) {
|
||||
xd = static_cast<const QWidget *>(fromDevice)->x11Info().x11data;
|
||||
} else {
|
||||
Q_ASSERT(fromDevice->devType() == QInternal::Pixmap);
|
||||
xd = static_cast<const QPixmap *>(fromDevice)->x11Info().x11data;
|
||||
}
|
||||
d = new QX11InfoData(*xd);
|
||||
d->ref = 0;
|
||||
}
|
||||
setX11Data(d);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Makes a shallow copy of the X11-specific data \a d and assigns it to this
|
||||
class. This function increments the reference code of \a d.
|
||||
*/
|
||||
|
||||
void QX11Info::setX11Data(const QX11InfoData* d)
|
||||
{
|
||||
if (x11data && !--x11data->ref)
|
||||
delete x11data;
|
||||
x11data = (QX11InfoData *)d;
|
||||
if (x11data)
|
||||
++x11data->ref;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
If \a def is false, returns a deep copy of the x11Data, or 0 if x11Data is 0.
|
||||
If \a def is true, makes a QX11Data struct filled with the default
|
||||
values.
|
||||
|
||||
In either case the caller is responsible for deleting the returned
|
||||
struct. But notice that the struct is a shared class, so other
|
||||
classes might also have a reference to it. The reference count of
|
||||
the returned QX11Data* is 0.
|
||||
*/
|
||||
|
||||
QX11InfoData* QX11Info::getX11Data(bool def) const
|
||||
{
|
||||
QX11InfoData* res = 0;
|
||||
if (def) {
|
||||
res = new QX11InfoData;
|
||||
res->ref = 0;
|
||||
res->screen = appScreen();
|
||||
res->depth = appDepth();
|
||||
res->cells = appCells();
|
||||
res->colormap = colormap();
|
||||
res->defaultColormap = appDefaultColormap();
|
||||
res->visual = (Visual*) appVisual();
|
||||
res->defaultVisual = appDefaultVisual();
|
||||
} else if (x11data) {
|
||||
res = new QX11InfoData;
|
||||
*res = *x11data;
|
||||
res->ref = 0;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the horizontal resolution of the given \a screen in terms of the
|
||||
number of dots per inch.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa setAppDpiX(), appDpiY()
|
||||
*/
|
||||
int QX11Info::appDpiX(int screen)
|
||||
{
|
||||
if (!X11)
|
||||
return 75;
|
||||
if (screen < 0)
|
||||
screen = X11->defaultScreen;
|
||||
if (screen > X11->screenCount)
|
||||
return 0;
|
||||
return X11->screens[screen].dpiX;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the horizontal resolution of the given \a screen to the number of
|
||||
dots per inch specified by \a xdpi.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa appDpiX(), setAppDpiY()
|
||||
*/
|
||||
|
||||
void QX11Info::setAppDpiX(int screen, int xdpi)
|
||||
{
|
||||
if (!X11)
|
||||
return;
|
||||
if (screen < 0)
|
||||
screen = X11->defaultScreen;
|
||||
if (screen > X11->screenCount)
|
||||
return;
|
||||
X11->screens[screen].dpiX = xdpi;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the vertical resolution of the given \a screen in terms of the
|
||||
number of dots per inch.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa setAppDpiY(), appDpiX()
|
||||
*/
|
||||
|
||||
int QX11Info::appDpiY(int screen)
|
||||
{
|
||||
if (!X11)
|
||||
return 75;
|
||||
if (screen < 0)
|
||||
screen = X11->defaultScreen;
|
||||
if (screen > X11->screenCount)
|
||||
return 0;
|
||||
return X11->screens[screen].dpiY;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the vertical resolution of the given \a screen to the number of
|
||||
dots per inch specified by \a ydpi.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa appDpiY(), setAppDpiX()
|
||||
*/
|
||||
void QX11Info::setAppDpiY(int screen, int ydpi)
|
||||
{
|
||||
if (!X11)
|
||||
return;
|
||||
if (screen < 0)
|
||||
screen = X11->defaultScreen;
|
||||
if (screen > X11->screenCount)
|
||||
return;
|
||||
X11->screens[screen].dpiY = ydpi;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the X11 time.
|
||||
|
||||
\sa setAppTime(), appUserTime()
|
||||
*/
|
||||
unsigned long QX11Info::appTime()
|
||||
{
|
||||
return X11 ? X11->time : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the X11 time to the value specified by \a time.
|
||||
|
||||
\sa appTime(), setAppUserTime()
|
||||
*/
|
||||
void QX11Info::setAppTime(unsigned long time)
|
||||
{
|
||||
if (X11) {
|
||||
X11->time = time;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the X11 user time.
|
||||
|
||||
\sa setAppUserTime(), appTime()
|
||||
*/
|
||||
unsigned long QX11Info::appUserTime()
|
||||
{
|
||||
return X11 ? X11->userTime : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the X11 user time as specified by \a time.
|
||||
|
||||
\sa appUserTime(), setAppTime()
|
||||
*/
|
||||
void QX11Info::setAppUserTime(unsigned long time)
|
||||
{
|
||||
if (X11) {
|
||||
X11->userTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn const char *QX11Info::appClass()
|
||||
|
||||
Returns the X11 application class.
|
||||
|
||||
\sa display()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the default display for the application.
|
||||
|
||||
\sa appScreen()
|
||||
*/
|
||||
|
||||
Display *QX11Info::display()
|
||||
{
|
||||
return X11 ? X11->display : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of the screen where the application is being
|
||||
displayed.
|
||||
|
||||
\sa display(), screen()
|
||||
*/
|
||||
int QX11Info::appScreen()
|
||||
{
|
||||
return X11 ? X11->defaultScreen : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a handle for the application's color map on the given \a screen.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa colormap(), defaultColormap()
|
||||
*/
|
||||
Qt::HANDLE QX11Info::appColormap(int screen)
|
||||
{
|
||||
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].colormap : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current visual used by the application on the given
|
||||
\a screen.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa visual(), defaultVisual()
|
||||
*/
|
||||
|
||||
void *QX11Info::appVisual(int screen)
|
||||
{
|
||||
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].visual : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a handle for the applications root window on the given \a screen.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa QApplication::desktop()
|
||||
*/
|
||||
Qt::HANDLE QX11Info::appRootWindow(int screen)
|
||||
{
|
||||
return X11 ? RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen) : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the color depth (bits per pixel) used by the application on the
|
||||
given \a screen.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa depth()
|
||||
*/
|
||||
|
||||
int QX11Info::appDepth(int screen)
|
||||
{
|
||||
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].depth : 32;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of cells used by the application on the given \a screen.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa cells()
|
||||
*/
|
||||
|
||||
int QX11Info::appCells(int screen)
|
||||
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].cells : 0; }
|
||||
|
||||
/*!
|
||||
Returns true if the application has a default color map on the given
|
||||
\a screen; otherwise returns false.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
*/
|
||||
bool QX11Info::appDefaultColormap(int screen)
|
||||
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].defaultColormap : true; }
|
||||
|
||||
/*!
|
||||
Returns true if the application has a default visual on the given \a screen;
|
||||
otherwise returns false.
|
||||
|
||||
The \a screen argument is an X screen number. Be aware that if
|
||||
the user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
*/
|
||||
bool QX11Info::appDefaultVisual(int screen)
|
||||
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].defaultVisual : true; }
|
||||
|
||||
/*!
|
||||
Returns the number of the screen currently in use.
|
||||
|
||||
The return value is an X screen number. Be aware that if the
|
||||
user's system uses Xinerama (as opposed to traditional X11
|
||||
multiscreen), there is only one X screen. Use QDesktopWidget to
|
||||
query for information about Xinerama screens.
|
||||
|
||||
\sa appScreen()
|
||||
*/
|
||||
int QX11Info::screen() const
|
||||
{ return x11data ? x11data->screen : QX11Info::appScreen(); }
|
||||
|
||||
/*!
|
||||
Returns the color depth (bits per pixel) of the X display.
|
||||
|
||||
\sa appDepth()
|
||||
*/
|
||||
|
||||
int QX11Info::depth() const
|
||||
{ return x11data ? x11data->depth : QX11Info::appDepth(); }
|
||||
|
||||
/*!
|
||||
Returns the number of cells.
|
||||
|
||||
\sa appCells()
|
||||
*/
|
||||
|
||||
int QX11Info::cells() const
|
||||
{ return x11data ? x11data->cells : QX11Info::appCells(); }
|
||||
|
||||
/*!
|
||||
Returns a handle for the color map.
|
||||
|
||||
\sa defaultColormap()
|
||||
*/
|
||||
|
||||
Qt::HANDLE QX11Info::colormap() const
|
||||
{ return x11data ? x11data->colormap : QX11Info::appColormap(); }
|
||||
|
||||
/*!
|
||||
Returns true if there is a default color map; otherwise returns false.
|
||||
|
||||
\sa colormap()
|
||||
*/
|
||||
|
||||
bool QX11Info::defaultColormap() const
|
||||
{ return x11data ? x11data->defaultColormap : QX11Info::appDefaultColormap(); }
|
||||
|
||||
/*!
|
||||
Returns the current visual.
|
||||
|
||||
\sa appVisual(), defaultVisual()
|
||||
*/
|
||||
|
||||
void *QX11Info::visual() const
|
||||
{ return x11data ? x11data->visual : QX11Info::appVisual(); }
|
||||
|
||||
/*!
|
||||
Returns true if there is a default visual; otherwise returns false.
|
||||
|
||||
\sa visual(), appVisual()
|
||||
*/
|
||||
|
||||
bool QX11Info::defaultVisual() const
|
||||
{ return x11data ? x11data->defaultVisual : QX11Info::appDefaultVisual(); }
|
||||
|
||||
|
||||
/*!
|
||||
\since 4.4
|
||||
|
||||
Returns true if there is a compositing manager running.
|
||||
*/
|
||||
bool QX11Info::isCompositingManagerRunning()
|
||||
{
|
||||
return X11 ? X11->compositingManagerRunning : false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,123 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QX11INFO_X11_H
|
||||
#define QX11INFO_X11_H
|
||||
|
||||
#include <QtCore/qnamespace.h>
|
||||
|
||||
typedef struct _XDisplay Display;
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
struct QX11InfoData;
|
||||
class QX11Info;
|
||||
class QPaintDevice;
|
||||
class QApplicationPrivate;
|
||||
class QX11InfoPrivate;
|
||||
struct QX11WindowAttributes;
|
||||
|
||||
void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &a);
|
||||
class Q_WIDGETS_EXPORT QX11Info
|
||||
{
|
||||
public:
|
||||
QX11Info();
|
||||
~QX11Info();
|
||||
QX11Info(const QX11Info &other);
|
||||
QX11Info &operator=(const QX11Info &other);
|
||||
|
||||
static Display *display();
|
||||
static const char *appClass();
|
||||
int screen() const;
|
||||
int depth() const;
|
||||
int cells() const;
|
||||
Qt::HANDLE colormap() const;
|
||||
bool defaultColormap() const;
|
||||
void *visual() const;
|
||||
bool defaultVisual() const;
|
||||
|
||||
static int appScreen();
|
||||
static int appDepth(int screen = -1);
|
||||
static int appCells(int screen = -1);
|
||||
static Qt::HANDLE appColormap(int screen = -1);
|
||||
static void *appVisual(int screen = -1);
|
||||
static Qt::HANDLE appRootWindow(int screen = -1);
|
||||
static bool appDefaultColormap(int screen = -1);
|
||||
static bool appDefaultVisual(int screen = -1);
|
||||
static int appDpiX(int screen = -1);
|
||||
static int appDpiY(int screen = -1);
|
||||
static void setAppDpiX(int screen, int dpi);
|
||||
static void setAppDpiY(int screen, int dpi);
|
||||
static unsigned long appTime();
|
||||
static unsigned long appUserTime();
|
||||
static void setAppTime(unsigned long time);
|
||||
static void setAppUserTime(unsigned long time);
|
||||
static bool isCompositingManagerRunning();
|
||||
|
||||
protected:
|
||||
void copyX11Data(const QPaintDevice *);
|
||||
void cloneX11Data(const QPaintDevice *);
|
||||
void setX11Data(const QX11InfoData *);
|
||||
QX11InfoData* getX11Data(bool def = false) const;
|
||||
|
||||
QX11InfoData *x11data;
|
||||
|
||||
friend class QX11PaintEngine;
|
||||
friend class QPixmap;
|
||||
friend class QX11PlatformPixmap;
|
||||
friend class QWidget;
|
||||
friend class QWidgetPrivate;
|
||||
friend class QGLWidget;
|
||||
friend void qt_init(QApplicationPrivate *priv, int, Display *display, Qt::HANDLE visual,
|
||||
Qt::HANDLE colormap);
|
||||
friend void qt_cleanup();
|
||||
friend void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &a);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QX11INFO_X11_H
|
@ -1,142 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Definition of QXIMInputContext class
|
||||
**
|
||||
** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
|
||||
**
|
||||
** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
|
||||
** license. You may use this file under your Qt license. Following
|
||||
** description is copied from their original file headers. Contact
|
||||
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QXIMINPUTCONTEXT_P_H
|
||||
#define QXIMINPUTCONTEXT_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#if !defined(Q_NO_IM)
|
||||
|
||||
#include "QtCore/qglobal.h"
|
||||
#include "QtWidgets/qinputcontext.h"
|
||||
#include "QtGui/qfont.h"
|
||||
#include "QtCore/qhash.h"
|
||||
#ifdef Q_WS_X11
|
||||
#include "QtCore/qlist.h"
|
||||
#include "QtCore/qbitarray.h"
|
||||
#include "QtGui/qwindowdefs.h"
|
||||
#include "private/qt_x11_p.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QKeyEvent;
|
||||
class QWidget;
|
||||
class QFont;
|
||||
class QString;
|
||||
|
||||
class QXIMInputContext : public QInputContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct ICData {
|
||||
XIC ic;
|
||||
XFontSet fontset;
|
||||
QWidget *widget;
|
||||
QString text;
|
||||
QBitArray selectedChars;
|
||||
bool composing;
|
||||
bool preeditEmpty;
|
||||
void clear();
|
||||
};
|
||||
|
||||
QXIMInputContext();
|
||||
~QXIMInputContext();
|
||||
|
||||
QString identifierName();
|
||||
QString language();
|
||||
|
||||
void reset();
|
||||
|
||||
void mouseHandler( int x, QMouseEvent *event);
|
||||
bool isComposing() const;
|
||||
|
||||
void setFocusWidget( QWidget *w );
|
||||
void widgetDestroyed(QWidget *w);
|
||||
|
||||
void create_xim();
|
||||
void close_xim();
|
||||
|
||||
void update();
|
||||
|
||||
ICData *icData() const;
|
||||
protected:
|
||||
bool x11FilterEvent( QWidget *keywidget, XEvent *event );
|
||||
|
||||
private:
|
||||
static XIMStyle xim_style;
|
||||
|
||||
QString _language;
|
||||
XIM xim;
|
||||
QHash<WId, ICData *> ximData;
|
||||
|
||||
ICData *createICData(QWidget *w);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // Q_NO_IM
|
||||
|
||||
#endif // QXIMINPUTCONTEXT_P_H
|
@ -1,885 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Implementation of QXIMInputContext class
|
||||
**
|
||||
** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
|
||||
**
|
||||
** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
|
||||
** license. You may use this file under your Qt license. Following
|
||||
** description is copied from their original file headers. Contact
|
||||
** immodule-qt@freedesktop.org if any conditions of this licensing are
|
||||
** not clear to you.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
#include "qdebug.h"
|
||||
#include "qximinputcontext_p.h"
|
||||
|
||||
#if !defined(QT_NO_IM)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_XIM)
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qwidget.h"
|
||||
#include "qstring.h"
|
||||
#include "qlist.h"
|
||||
#include "qtextcodec.h"
|
||||
#include "qevent.h"
|
||||
#include "qtextformat.h"
|
||||
|
||||
#include "qx11info_x11.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
// #define QT_XIM_DEBUG
|
||||
#ifdef QT_XIM_DEBUG
|
||||
#define XIM_DEBUG qDebug
|
||||
#else
|
||||
#define XIM_DEBUG if (0) qDebug
|
||||
#endif
|
||||
|
||||
// from qapplication_x11.cpp
|
||||
// #### move to X11 struct
|
||||
extern XIMStyle qt_xim_preferred_style;
|
||||
extern char *qt_ximServer;
|
||||
extern int qt_ximComposingKeycode;
|
||||
extern QTextCodec * qt_input_mapper;
|
||||
|
||||
XIMStyle QXIMInputContext::xim_style = 0;
|
||||
// moved from qapplication_x11.cpp
|
||||
static const XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing;
|
||||
|
||||
|
||||
extern "C" {
|
||||
#ifdef USE_X11R6_XIM
|
||||
static void xim_create_callback(XIM /*im*/,
|
||||
XPointer client_data,
|
||||
XPointer /*call_data*/)
|
||||
{
|
||||
QXIMInputContext *qic = reinterpret_cast<QXIMInputContext *>(client_data);
|
||||
// qDebug("xim_create_callback");
|
||||
qic->create_xim();
|
||||
}
|
||||
|
||||
static void xim_destroy_callback(XIM /*im*/,
|
||||
XPointer client_data,
|
||||
XPointer /*call_data*/)
|
||||
{
|
||||
QXIMInputContext *qic = reinterpret_cast<QXIMInputContext *>(client_data);
|
||||
// qDebug("xim_destroy_callback");
|
||||
qic->close_xim();
|
||||
XRegisterIMInstantiateCallback(X11->display, 0, 0, 0,
|
||||
(XIMProc) xim_create_callback, reinterpret_cast<char *>(qic));
|
||||
}
|
||||
#endif // USE_X11R6_XIM
|
||||
|
||||
static int xic_start_callback(XIC, XPointer client_data, XPointer) {
|
||||
QXIMInputContext *qic = (QXIMInputContext *) client_data;
|
||||
if (!qic) {
|
||||
XIM_DEBUG("xic_start_callback: no qic");
|
||||
return 0;
|
||||
}
|
||||
QXIMInputContext::ICData *data = qic->icData();
|
||||
if (!data) {
|
||||
XIM_DEBUG("xic_start_callback: no ic data");
|
||||
return 0;
|
||||
}
|
||||
XIM_DEBUG("xic_start_callback");
|
||||
|
||||
data->clear();
|
||||
data->composing = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xic_draw_callback(XIC, XPointer client_data, XPointer call_data) {
|
||||
QXIMInputContext *qic = (QXIMInputContext *) client_data;
|
||||
if (!qic) {
|
||||
XIM_DEBUG("xic_draw_callback: no qic");
|
||||
return 0;
|
||||
}
|
||||
QXIMInputContext::ICData *data = qic->icData();
|
||||
if (!data) {
|
||||
XIM_DEBUG("xic_draw_callback: no ic data");
|
||||
return 0;
|
||||
}
|
||||
XIM_DEBUG("xic_draw_callback");
|
||||
|
||||
|
||||
if(!data->composing) {
|
||||
data->clear();
|
||||
data->composing = true;
|
||||
}
|
||||
|
||||
XIMPreeditDrawCallbackStruct *drawstruct = (XIMPreeditDrawCallbackStruct *) call_data;
|
||||
XIMText *text = (XIMText *) drawstruct->text;
|
||||
int cursor = drawstruct->caret, sellen = 0, selstart = 0;
|
||||
|
||||
if (!drawstruct->caret && !drawstruct->chg_first && !drawstruct->chg_length && !text) {
|
||||
if(data->text.isEmpty()) {
|
||||
XIM_DEBUG("compose emptied");
|
||||
// if the composition string has been emptied, we need
|
||||
// to send an InputMethodEnd event
|
||||
QInputMethodEvent e;
|
||||
qic->sendEvent(e);
|
||||
data->clear();
|
||||
|
||||
// if the commit string has coming after here, InputMethodStart
|
||||
// will be sent dynamically
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (text) {
|
||||
char *str = 0;
|
||||
if (text->encoding_is_wchar) {
|
||||
int l = wcstombs(NULL, text->string.wide_char, text->length);
|
||||
if (l != -1) {
|
||||
str = new char[l + 1];
|
||||
wcstombs(str, text->string.wide_char, l);
|
||||
str[l] = 0;
|
||||
}
|
||||
} else
|
||||
str = text->string.multi_byte;
|
||||
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
QString s = QString::fromLocal8Bit(str);
|
||||
|
||||
if (text->encoding_is_wchar)
|
||||
delete [] str;
|
||||
|
||||
if (drawstruct->chg_length < 0)
|
||||
data->text.replace(drawstruct->chg_first, INT_MAX, s);
|
||||
else
|
||||
data->text.replace(drawstruct->chg_first, drawstruct->chg_length, s);
|
||||
|
||||
if (data->selectedChars.size() < data->text.length()) {
|
||||
// expand the selectedChars array if the compose string is longer
|
||||
int from = data->selectedChars.size();
|
||||
data->selectedChars.resize(data->text.length());
|
||||
for (int x = from; x < data->selectedChars.size(); ++x)
|
||||
data->selectedChars.clearBit(x);
|
||||
}
|
||||
|
||||
// determine if the changed chars are selected based on text->feedback
|
||||
for (int x = 0; x < text->length; ++x)
|
||||
data->selectedChars.setBit(x + drawstruct->chg_first,
|
||||
(text->feedback ? (text->feedback[x] & XIMReverse) : 0));
|
||||
|
||||
// figure out where the selection starts, and how long it is
|
||||
bool started = false;
|
||||
for (int x = 0; x < qMin(data->selectedChars.size(), data->text.length()); ++x) {
|
||||
if (started) {
|
||||
if (data->selectedChars.testBit(x)) ++sellen;
|
||||
else break;
|
||||
} else {
|
||||
if (data->selectedChars.testBit(x)) {
|
||||
selstart = x;
|
||||
started = true;
|
||||
sellen = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (drawstruct->chg_length == 0)
|
||||
drawstruct->chg_length = -1;
|
||||
|
||||
data->text.remove(drawstruct->chg_first, drawstruct->chg_length);
|
||||
bool qt_compose_emptied = data->text.isEmpty();
|
||||
if (qt_compose_emptied) {
|
||||
XIM_DEBUG("compose emptied 2 text=%s", data->text.toUtf8().constData());
|
||||
// if the composition string has been emptied, we need
|
||||
// to send an InputMethodEnd event
|
||||
QInputMethodEvent e;
|
||||
qic->sendEvent(e);
|
||||
data->clear();
|
||||
// if the commit string has coming after here, InputMethodStart
|
||||
// will be sent dynamically
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
XIM_DEBUG("sending compose: '%s', cursor=%d, sellen=%d",
|
||||
data->text.toUtf8().constData(), cursor, sellen);
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
if (selstart > 0)
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, selstart,
|
||||
qic->standardFormat(QInputContext::PreeditFormat));
|
||||
if (sellen)
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selstart, sellen,
|
||||
qic->standardFormat(QInputContext::SelectionFormat));
|
||||
if (selstart + sellen < data->text.length())
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
|
||||
selstart + sellen, data->text.length() - selstart - sellen,
|
||||
qic->standardFormat(QInputContext::PreeditFormat));
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, sellen ? 0 : 1, QVariant());
|
||||
QInputMethodEvent e(data->text, attrs);
|
||||
data->preeditEmpty = data->text.isEmpty();
|
||||
qic->sendEvent(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xic_done_callback(XIC, XPointer client_data, XPointer) {
|
||||
QXIMInputContext *qic = (QXIMInputContext *) client_data;
|
||||
if (!qic)
|
||||
return 0;
|
||||
|
||||
XIM_DEBUG("xic_done_callback");
|
||||
// Don't send InputMethodEnd here. QXIMInputContext::x11FilterEvent()
|
||||
// handles InputMethodEnd with commit string.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QXIMInputContext::ICData::clear()
|
||||
{
|
||||
text = QString();
|
||||
selectedChars.clear();
|
||||
composing = false;
|
||||
preeditEmpty = true;
|
||||
}
|
||||
|
||||
QXIMInputContext::ICData *QXIMInputContext::icData() const
|
||||
{
|
||||
if (QWidget *w = focusWidget())
|
||||
return ximData.value(w->effectiveWinId());
|
||||
return 0;
|
||||
}
|
||||
/* The cache here is needed, as X11 leaks a few kb for every
|
||||
XFreeFontSet call, so we avoid creating and deletion of fontsets as
|
||||
much as possible
|
||||
*/
|
||||
static XFontSet fontsetCache[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static int fontsetRefCount = 0;
|
||||
|
||||
static const char * const fontsetnames[] = {
|
||||
"-*-fixed-medium-r-*-*-16-*,-*-*-medium-r-*-*-16-*",
|
||||
"-*-fixed-medium-i-*-*-16-*,-*-*-medium-i-*-*-16-*",
|
||||
"-*-fixed-bold-r-*-*-16-*,-*-*-bold-r-*-*-16-*",
|
||||
"-*-fixed-bold-i-*-*-16-*,-*-*-bold-i-*-*-16-*",
|
||||
"-*-fixed-medium-r-*-*-24-*,-*-*-medium-r-*-*-24-*",
|
||||
"-*-fixed-medium-i-*-*-24-*,-*-*-medium-i-*-*-24-*",
|
||||
"-*-fixed-bold-r-*-*-24-*,-*-*-bold-r-*-*-24-*",
|
||||
"-*-fixed-bold-i-*-*-24-*,-*-*-bold-i-*-*-24-*"
|
||||
};
|
||||
|
||||
static XFontSet getFontSet(const QFont &f)
|
||||
{
|
||||
int i = 0;
|
||||
if (f.italic())
|
||||
i |= 1;
|
||||
if (f.bold())
|
||||
i |= 2;
|
||||
|
||||
if (f.pointSize() > 20)
|
||||
i += 4;
|
||||
|
||||
if (!fontsetCache[i]) {
|
||||
Display* dpy = X11->display;
|
||||
int missCount;
|
||||
char** missList;
|
||||
fontsetCache[i] = XCreateFontSet(dpy, fontsetnames[i], &missList, &missCount, 0);
|
||||
if(missCount > 0)
|
||||
XFreeStringList(missList);
|
||||
if (!fontsetCache[i]) {
|
||||
fontsetCache[i] = XCreateFontSet(dpy, "-*-fixed-*-*-*-*-16-*", &missList, &missCount, 0);
|
||||
if(missCount > 0)
|
||||
XFreeStringList(missList);
|
||||
if (!fontsetCache[i])
|
||||
fontsetCache[i] = (XFontSet)-1;
|
||||
}
|
||||
}
|
||||
return (fontsetCache[i] == (XFontSet)-1) ? 0 : fontsetCache[i];
|
||||
}
|
||||
|
||||
extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp
|
||||
#ifndef QT_NO_XKB
|
||||
extern QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName);
|
||||
#endif
|
||||
|
||||
QXIMInputContext::QXIMInputContext()
|
||||
{
|
||||
if (!qt_xim_preferred_style) // no configured input style, use the default
|
||||
qt_xim_preferred_style = xim_default_style;
|
||||
|
||||
xim = 0;
|
||||
QByteArray ximServerName(qt_ximServer);
|
||||
if (qt_ximServer)
|
||||
ximServerName.prepend("@im=");
|
||||
else
|
||||
ximServerName = "";
|
||||
|
||||
if (!XSupportsLocale())
|
||||
#ifndef QT_NO_DEBUG
|
||||
qWarning("Qt: Locale not supported on X server")
|
||||
#endif
|
||||
;
|
||||
#ifdef USE_X11R6_XIM
|
||||
else if (XSetLocaleModifiers (ximServerName.constData()) == 0)
|
||||
qWarning("Qt: Cannot set locale modifiers: %s", ximServerName.constData());
|
||||
else
|
||||
XRegisterIMInstantiateCallback(X11->display, 0, 0, 0,
|
||||
(XIMProc) xim_create_callback, reinterpret_cast<char *>(this));
|
||||
#else // !USE_X11R6_XIM
|
||||
else if (XSetLocaleModifiers ("") == 0)
|
||||
qWarning("Qt: Cannot set locale modifiers");
|
||||
else
|
||||
QXIMInputContext::create_xim();
|
||||
#endif // USE_X11R6_XIM
|
||||
|
||||
#ifndef QT_NO_XKB
|
||||
if (X11->use_xkb) {
|
||||
QByteArray layoutName;
|
||||
QByteArray variantName;
|
||||
|
||||
Atom type = XNone;
|
||||
int format = 0;
|
||||
ulong nitems = 0;
|
||||
ulong bytesAfter = 0;
|
||||
uchar *data = 0;
|
||||
if (XGetWindowProperty(X11->display, RootWindow(X11->display, 0), ATOM(_XKB_RULES_NAMES), 0, 1024,
|
||||
false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) == Success
|
||||
&& type == XA_STRING && format == 8 && nitems > 2) {
|
||||
|
||||
char *names[5] = { 0, 0, 0, 0, 0 };
|
||||
char *p = reinterpret_cast<char *>(data), *end = p + nitems;
|
||||
int i = 0;
|
||||
do {
|
||||
names[i++] = p;
|
||||
p += qstrlen(p) + 1;
|
||||
} while (p < end);
|
||||
|
||||
QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(',');
|
||||
QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(',');
|
||||
for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i ) {
|
||||
QByteArray variantName = variantNames.at(i);
|
||||
const int dashPos = variantName.indexOf("-");
|
||||
if (dashPos >= 0)
|
||||
variantName.truncate(dashPos);
|
||||
QLocale keyboardInputLocale = q_getKeyboardLocale(layoutNames.at(i), variantName);
|
||||
if (keyboardInputLocale.textDirection() == Qt::RightToLeft)
|
||||
qt_use_rtl_extensions = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (data)
|
||||
XFree(data);
|
||||
}
|
||||
#endif // QT_NO_XKB
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*!\internal
|
||||
Creates the application input method.
|
||||
*/
|
||||
void QXIMInputContext::create_xim()
|
||||
{
|
||||
++fontsetRefCount;
|
||||
#ifndef QT_NO_XIM
|
||||
xim = XOpenIM(X11->display, 0, 0, 0);
|
||||
if (xim) {
|
||||
|
||||
#ifdef USE_X11R6_XIM
|
||||
XIMCallback destroy;
|
||||
destroy.callback = (XIMProc) xim_destroy_callback;
|
||||
destroy.client_data = XPointer(this);
|
||||
if (XSetIMValues(xim, XNDestroyCallback, &destroy, (char *) 0) != 0)
|
||||
qWarning("Xlib doesn't support destroy callback");
|
||||
#endif // USE_X11R6_XIM
|
||||
|
||||
XIMStyles *styles = 0;
|
||||
XGetIMValues(xim, XNQueryInputStyle, &styles, (char *) 0, (char *) 0);
|
||||
if (styles) {
|
||||
int i;
|
||||
for (i = 0; !xim_style && i < styles->count_styles; i++) {
|
||||
if (styles->supported_styles[i] == qt_xim_preferred_style) {
|
||||
xim_style = qt_xim_preferred_style;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if the preferred input style couldn't be found, look for
|
||||
// Nothing
|
||||
for (i = 0; !xim_style && i < styles->count_styles; i++) {
|
||||
if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) {
|
||||
xim_style = XIMPreeditNothing | XIMStatusNothing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ... and failing that, None.
|
||||
for (i = 0; !xim_style && i < styles->count_styles; i++) {
|
||||
if (styles->supported_styles[i] == (XIMPreeditNone |
|
||||
XIMStatusNone)) {
|
||||
xim_style = XIMPreeditNone | XIMStatusNone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// qDebug("QApplication: using im style %lx", xim_style);
|
||||
XFree((char *)styles);
|
||||
}
|
||||
|
||||
if (xim_style) {
|
||||
|
||||
#ifdef USE_X11R6_XIM
|
||||
XUnregisterIMInstantiateCallback(X11->display, 0, 0, 0,
|
||||
(XIMProc) xim_create_callback, reinterpret_cast<char *>(this));
|
||||
#endif // USE_X11R6_XIM
|
||||
|
||||
if (QWidget *focusWidget = QApplication::focusWidget()) {
|
||||
// reinitialize input context after the input method
|
||||
// server (like SCIM) has been launched without
|
||||
// requiring the user to manually switch focus.
|
||||
if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)
|
||||
&& focusWidget->testAttribute(Qt::WA_WState_Created)
|
||||
&& focusWidget->isEnabled())
|
||||
setFocusWidget(focusWidget);
|
||||
}
|
||||
// following code fragment is not required for immodule
|
||||
// version of XIM
|
||||
#if 0
|
||||
QWidgetList list = qApp->topLevelWidgets();
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QWidget *w = list.at(i);
|
||||
w->d->createTLSysExtra();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Give up
|
||||
qWarning("No supported input style found."
|
||||
" See InputMethod documentation.");
|
||||
close_xim();
|
||||
}
|
||||
}
|
||||
#endif // QT_NO_XIM
|
||||
}
|
||||
|
||||
/*!\internal
|
||||
Closes the application input method.
|
||||
*/
|
||||
void QXIMInputContext::close_xim()
|
||||
{
|
||||
for(QHash<WId, ICData *>::const_iterator i = ximData.constBegin(),
|
||||
e = ximData.constEnd(); i != e; ++i) {
|
||||
ICData *data = i.value();
|
||||
if (data->ic)
|
||||
XDestroyIC(data->ic);
|
||||
delete data;
|
||||
}
|
||||
ximData.clear();
|
||||
|
||||
if ( --fontsetRefCount == 0 ) {
|
||||
Display *dpy = X11->display;
|
||||
for ( int i = 0; i < 8; i++ ) {
|
||||
if ( fontsetCache[i] && fontsetCache[i] != (XFontSet)-1 ) {
|
||||
XFreeFontSet(dpy, fontsetCache[i]);
|
||||
fontsetCache[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setFocusWidget(0);
|
||||
xim = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QXIMInputContext::~QXIMInputContext()
|
||||
{
|
||||
XIM old_xim = xim; // close_xim clears xim pointer.
|
||||
close_xim();
|
||||
if (old_xim)
|
||||
XCloseIM(old_xim);
|
||||
}
|
||||
|
||||
|
||||
QString QXIMInputContext::identifierName()
|
||||
{
|
||||
// the name should be "xim" rather than "XIM" to be consistent
|
||||
// with corresponding immodule of GTK+
|
||||
return QLatin1String("xim");
|
||||
}
|
||||
|
||||
|
||||
QString QXIMInputContext::language()
|
||||
{
|
||||
QString language;
|
||||
if (xim) {
|
||||
QByteArray locale(XLocaleOfIM(xim));
|
||||
|
||||
if (locale.startsWith("zh")) {
|
||||
// Chinese language should be formed as "zh_CN", "zh_TW", "zh_HK"
|
||||
language = QLatin1String(locale.left(5));
|
||||
} else {
|
||||
// other languages should be two-letter ISO 639 language code
|
||||
language = QLatin1String(locale.left(2));
|
||||
}
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
void QXIMInputContext::reset()
|
||||
{
|
||||
QWidget *w = focusWidget();
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
if (data->ic) {
|
||||
char *mb = XmbResetIC(data->ic);
|
||||
QInputMethodEvent e;
|
||||
if (mb) {
|
||||
e.setCommitString(QString::fromLocal8Bit(mb));
|
||||
XFree(mb);
|
||||
data->preeditEmpty = false; // force sending an event
|
||||
}
|
||||
if (!data->preeditEmpty) {
|
||||
sendEvent(e);
|
||||
update();
|
||||
}
|
||||
}
|
||||
data->clear();
|
||||
}
|
||||
|
||||
void QXIMInputContext::widgetDestroyed(QWidget *w)
|
||||
{
|
||||
QInputContext::widgetDestroyed(w);
|
||||
ICData *data = ximData.take(w->effectiveWinId());
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
data->clear();
|
||||
if (data->ic)
|
||||
XDestroyIC(data->ic);
|
||||
delete data;
|
||||
}
|
||||
|
||||
void QXIMInputContext::mouseHandler(int pos, QMouseEvent *e)
|
||||
{
|
||||
if(e->type() != QEvent::MouseButtonPress)
|
||||
return;
|
||||
|
||||
XIM_DEBUG("QXIMInputContext::mouseHandler pos=%d", pos);
|
||||
if (QWidget *w = focusWidget()) {
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data)
|
||||
return;
|
||||
if (pos < 0 || pos > data->text.length())
|
||||
reset();
|
||||
// ##### handle mouse position
|
||||
}
|
||||
}
|
||||
|
||||
bool QXIMInputContext::isComposing() const
|
||||
{
|
||||
QWidget *w = focusWidget();
|
||||
if (!w)
|
||||
return false;
|
||||
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data)
|
||||
return false;
|
||||
return data->composing;
|
||||
}
|
||||
|
||||
void QXIMInputContext::setFocusWidget(QWidget *w)
|
||||
{
|
||||
if (!xim)
|
||||
return;
|
||||
QWidget *oldFocus = focusWidget();
|
||||
if (oldFocus == w)
|
||||
return;
|
||||
|
||||
if (language() != QLatin1String("ja"))
|
||||
reset();
|
||||
|
||||
if (oldFocus) {
|
||||
ICData *data = ximData.value(oldFocus->effectiveWinId());
|
||||
if (data && data->ic)
|
||||
XUnsetICFocus(data->ic);
|
||||
}
|
||||
|
||||
QInputContext::setFocusWidget(w);
|
||||
|
||||
if (!w || w->inputMethodHints() & (Qt::ImhExclusiveInputMask | Qt::ImhHiddenText))
|
||||
return;
|
||||
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data)
|
||||
data = createICData(w);
|
||||
|
||||
if (data->ic)
|
||||
XSetICFocus(data->ic);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
bool QXIMInputContext::x11FilterEvent(QWidget *keywidget, XEvent *event)
|
||||
{
|
||||
int xkey_keycode = event->xkey.keycode;
|
||||
if (!keywidget->testAttribute(Qt::WA_WState_Created))
|
||||
return false;
|
||||
if (XFilterEvent(event, keywidget->effectiveWinId())) {
|
||||
qt_ximComposingKeycode = xkey_keycode; // ### not documented in xlib
|
||||
|
||||
update();
|
||||
|
||||
return true;
|
||||
}
|
||||
if (event->type != XKeyPress || event->xkey.keycode != 0)
|
||||
return false;
|
||||
|
||||
QWidget *w = focusWidget();
|
||||
if (keywidget != w)
|
||||
return false;
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
// input method has sent us a commit string
|
||||
QByteArray string;
|
||||
string.resize(513);
|
||||
KeySym key; // unused
|
||||
Status status; // unused
|
||||
QString text;
|
||||
int count = XmbLookupString(data->ic, &event->xkey, string.data(), string.size(),
|
||||
&key, &status);
|
||||
|
||||
if (status == XBufferOverflow) {
|
||||
string.resize(count + 1);
|
||||
count = XmbLookupString(data->ic, &event->xkey, string.data(), string.size(),
|
||||
&key, &status);
|
||||
}
|
||||
if (count > 0) {
|
||||
// XmbLookupString() gave us some text, convert it to unicode
|
||||
text = qt_input_mapper->toUnicode(string.constData() , count);
|
||||
if (text.isEmpty()) {
|
||||
// codec couldn't convert to unicode? this can happen when running in the
|
||||
// C locale (or with no LANG set). try converting from latin-1
|
||||
text = QString::fromLatin1(string.constData(), count);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!(xim_style & XIMPreeditCallbacks) || !isComposing()) {
|
||||
// ############### send a regular key event here!
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
QInputMethodEvent e;
|
||||
e.setCommitString(text);
|
||||
sendEvent(e);
|
||||
data->clear();
|
||||
|
||||
update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QXIMInputContext::ICData *QXIMInputContext::createICData(QWidget *w)
|
||||
{
|
||||
ICData *data = new ICData;
|
||||
data->widget = w;
|
||||
data->preeditEmpty = true;
|
||||
|
||||
XVaNestedList preedit_attr = 0;
|
||||
XIMCallback startcallback, drawcallback, donecallback;
|
||||
|
||||
QFont font = w->font();
|
||||
data->fontset = getFontSet(font);
|
||||
|
||||
if (xim_style & XIMPreeditArea) {
|
||||
XRectangle rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = w->width();
|
||||
rect.height = w->height();
|
||||
|
||||
preedit_attr = XVaCreateNestedList(0,
|
||||
XNArea, &rect,
|
||||
XNFontSet, data->fontset,
|
||||
(char *) 0);
|
||||
} else if (xim_style & XIMPreeditPosition) {
|
||||
XPoint spot;
|
||||
spot.x = 1;
|
||||
spot.y = 1;
|
||||
|
||||
preedit_attr = XVaCreateNestedList(0,
|
||||
XNSpotLocation, &spot,
|
||||
XNFontSet, data->fontset,
|
||||
(char *) 0);
|
||||
} else if (xim_style & XIMPreeditCallbacks) {
|
||||
startcallback.client_data = (XPointer) this;
|
||||
startcallback.callback = (XIMProc) xic_start_callback;
|
||||
drawcallback.client_data = (XPointer) this;
|
||||
drawcallback.callback = (XIMProc)xic_draw_callback;
|
||||
donecallback.client_data = (XPointer) this;
|
||||
donecallback.callback = (XIMProc) xic_done_callback;
|
||||
|
||||
preedit_attr = XVaCreateNestedList(0,
|
||||
XNPreeditStartCallback, &startcallback,
|
||||
XNPreeditDrawCallback, &drawcallback,
|
||||
XNPreeditDoneCallback, &donecallback,
|
||||
(char *) 0);
|
||||
}
|
||||
|
||||
if (preedit_attr) {
|
||||
data->ic = XCreateIC(xim,
|
||||
XNInputStyle, xim_style,
|
||||
XNClientWindow, w->effectiveWinId(),
|
||||
XNPreeditAttributes, preedit_attr,
|
||||
(char *) 0);
|
||||
XFree(preedit_attr);
|
||||
} else {
|
||||
data->ic = XCreateIC(xim,
|
||||
XNInputStyle, xim_style,
|
||||
XNClientWindow, w->effectiveWinId(),
|
||||
(char *) 0);
|
||||
}
|
||||
|
||||
if (data->ic) {
|
||||
// when resetting the input context, preserve the input state
|
||||
(void) XSetICValues(data->ic, XNResetState, XIMPreserveState, (char *) 0);
|
||||
} else {
|
||||
qWarning("Failed to create XIC");
|
||||
}
|
||||
|
||||
ximData[w->effectiveWinId()] = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
void QXIMInputContext::update()
|
||||
{
|
||||
QWidget *w = focusWidget();
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
ICData *data = ximData.value(w->effectiveWinId());
|
||||
if (!data || !data->ic)
|
||||
return;
|
||||
|
||||
QRect r = w->inputMethodQuery(Qt::ImMicroFocus).toRect();
|
||||
QPoint p;
|
||||
if (w->nativeParentWidget())
|
||||
p = w->mapTo(w->nativeParentWidget(), QPoint((r.left() + r.right() + 1)/2, r.bottom()));
|
||||
else
|
||||
p = QPoint((r.left() + r.right() + 1)/2, r.bottom());
|
||||
XPoint spot;
|
||||
spot.x = p.x();
|
||||
spot.y = p.y();
|
||||
|
||||
r = w->rect();
|
||||
XRectangle area;
|
||||
area.x = r.x();
|
||||
area.y = r.y();
|
||||
area.width = r.width();
|
||||
area.height = r.height();
|
||||
|
||||
XFontSet fontset = getFontSet(qvariant_cast<QFont>(w->inputMethodQuery(Qt::ImFont)));
|
||||
if (data->fontset == fontset)
|
||||
fontset = 0;
|
||||
else
|
||||
data->fontset = fontset;
|
||||
|
||||
XVaNestedList preedit_attr;
|
||||
if (fontset)
|
||||
preedit_attr = XVaCreateNestedList(0,
|
||||
XNSpotLocation, &spot,
|
||||
XNArea, &area,
|
||||
XNFontSet, fontset,
|
||||
(char *) 0);
|
||||
else
|
||||
preedit_attr = XVaCreateNestedList(0,
|
||||
XNSpotLocation, &spot,
|
||||
XNArea, &area,
|
||||
(char *) 0);
|
||||
|
||||
XSetICValues(data->ic, XNPreeditAttributes, preedit_attr, (char *) 0);
|
||||
XFree(preedit_attr);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
/*
|
||||
When QT_NO_XIM is defined, we provide a dummy implementation for
|
||||
this class. The reason for this is that the header file is moc'ed
|
||||
regardless of QT_NO_XIM. The best would be to remove the file
|
||||
completely from the pri file is QT_NO_XIM was defined, or for moc
|
||||
to understand this preprocessor directive. Since the header does
|
||||
not declare this class when QT_NO_XIM is defined, this is dead
|
||||
code.
|
||||
*/
|
||||
bool QXIMInputContext::isComposing() const { return false; }
|
||||
QString QXIMInputContext::identifierName() { return QString(); }
|
||||
void QXIMInputContext::mouseHandler(int, QMouseEvent *) {}
|
||||
void QXIMInputContext::setFocusWidget(QWidget *) {}
|
||||
void QXIMInputContext::reset() {}
|
||||
void QXIMInputContext::update() {}
|
||||
QXIMInputContext::~QXIMInputContext() {}
|
||||
void QXIMInputContext::widgetDestroyed(QWidget *) {}
|
||||
QString QXIMInputContext::language() { return QString(); }
|
||||
bool QXIMInputContext::x11FilterEvent(QWidget *, XEvent *) { return true; }
|
||||
|
||||
#endif //QT_NO_XIM
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_IM
|
@ -73,7 +73,6 @@
|
||||
#include <QtWidgets/QMenuBar>
|
||||
#include <QtWidgets/QToolBar>
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QX11Info>
|
||||
|
||||
#include <private/qt_x11_p.h>
|
||||
|
||||
@ -947,7 +946,9 @@ void QGtkStylePrivate::setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *p
|
||||
XSetTransientForHint(QGtkStylePrivate::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
|
||||
QGtkStylePrivate::gdk_x11_drawable_get_xid(gtkFileChooser->window),
|
||||
modalFor->winId());
|
||||
#ifdef Q_WS_X11
|
||||
QGtkStylePrivate::gdk_x11_window_set_user_time (gtkFileChooser->window, QX11Info::appUserTime());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -72,10 +72,6 @@
|
||||
#include <QtWidgets/qgraphicsproxywidget.h>
|
||||
#include <QtWidgets/qgraphicsview.h>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include "qx11info_x11.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// old constants that might still be useful...
|
||||
@ -2693,13 +2689,9 @@ QMotifStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w
|
||||
/*! \reimp */
|
||||
QPalette QMotifStyle::standardPalette() const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QColor background(0xcf, 0xcf, 0xcf);
|
||||
if (QX11Info::appDepth() <= 8)
|
||||
if (QPixmap::defaultDepth() <= 8)
|
||||
background = QColor(0xc0, 0xc0, 0xc0);
|
||||
#else
|
||||
QColor background = QColor(0xcf, 0xcf, 0xcf);
|
||||
#endif
|
||||
|
||||
QColor light = background.lighter();
|
||||
QColor mid = QColor(0xa6, 0xa6, 0xa6);
|
||||
|
@ -52,10 +52,6 @@
|
||||
#include "qdebug.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <qx11info_x11.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -2194,15 +2190,8 @@ int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool up
|
||||
*/
|
||||
QPalette QStyle::standardPalette() const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QColor background;
|
||||
if (QX11Info::appDepth() > 8)
|
||||
background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
|
||||
else
|
||||
background = QColor(192, 192, 192);
|
||||
#else
|
||||
QColor background(0xd4, 0xd0, 0xc8); // win 2000 grey
|
||||
#endif
|
||||
QColor background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
|
||||
|
||||
QColor light(background.lighter());
|
||||
QColor dark(background.darker());
|
||||
QColor mid(Qt::gray);
|
||||
|
@ -11,8 +11,7 @@ SUBDIRS=\
|
||||
qwindowsurface \
|
||||
qwsembedwidget \
|
||||
qwsinputmethod \
|
||||
qwswindowsystem \
|
||||
qx11info \
|
||||
qwswindowsystem
|
||||
|
||||
# This test cannot be run on Mac OS
|
||||
mac*:SUBDIRS -= \
|
||||
|
@ -65,10 +65,6 @@
|
||||
#include <qscreen_qws.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
|
||||
//TESTED_CLASS=
|
||||
//TESTED_FILES=
|
||||
|
||||
@ -180,10 +176,8 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
|
||||
int size = actual.width() * actual.height();
|
||||
|
||||
int threshold = 2;
|
||||
#ifdef Q_WS_X11
|
||||
if (QX11Info::appDepth() == 16)
|
||||
if (QPixmap::defaultDepth() == 16)
|
||||
threshold = 10;
|
||||
#endif
|
||||
|
||||
QRgb *a = (QRgb *)actualImage.bits();
|
||||
QRgb *e = (QRgb *)expectedImage.bits();
|
||||
@ -245,10 +239,8 @@ void tst_QPixmap::swap()
|
||||
void tst_QPixmap::fromImage_data()
|
||||
{
|
||||
bool is16bit = false;
|
||||
#ifdef Q_WS_X11
|
||||
if (QX11Info::appDepth() == 16)
|
||||
if (QPixmap::defaultDepth() == 16)
|
||||
is16bit = true;
|
||||
#endif
|
||||
|
||||
QTest::addColumn<QImage::Format>("format");
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include <QPalette>
|
||||
#include <QWindowsStyle>
|
||||
#include <QDesktopWidget>
|
||||
#include <QX11Info>
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <private/qwindowsurface_p.h>
|
||||
|
1
tests/auto/qx11info/.gitignore
vendored
1
tests/auto/qx11info/.gitignore
vendored
@ -1 +0,0 @@
|
||||
tst_qx11info
|
@ -1,7 +0,0 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qx11info
|
||||
QT += widgets testlib
|
||||
SOURCES += tst_qx11info.cpp
|
||||
|
||||
|
||||
mac*:CONFIG+=insignificant_test
|
@ -1,127 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QApplication>
|
||||
#include <QX11Info>
|
||||
|
||||
class tst_QX11Info : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef Q_WS_X11
|
||||
public slots:
|
||||
void initTestCase();
|
||||
#else
|
||||
private slots:
|
||||
void staticFunctionsBeforeQApplication();
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef Q_WS_X11
|
||||
void tst_QX11Info::initTestCase()
|
||||
{
|
||||
QSKIP("This test is only valid for X11");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void tst_QX11Info::staticFunctionsBeforeQApplication()
|
||||
{
|
||||
QVERIFY(!QApplication::instance());
|
||||
|
||||
// none of these functions should crash if QApplication hasn't
|
||||
// been constructed
|
||||
|
||||
Display *display = QX11Info::display();
|
||||
QCOMPARE(display, (Display *)0);
|
||||
const char *appClass = QX11Info::appClass();
|
||||
QCOMPARE(appClass, (const char *)0);
|
||||
int appScreen = QX11Info::appScreen();
|
||||
QCOMPARE(appScreen, 0);
|
||||
int appDepth = QX11Info::appDepth();
|
||||
QCOMPARE(appDepth, 32);
|
||||
int appCells = QX11Info::appCells();
|
||||
QCOMPARE(appCells, 0);
|
||||
Qt::HANDLE appColormap = QX11Info::appColormap();
|
||||
QCOMPARE(appColormap, static_cast<Qt::HANDLE>(0));
|
||||
void *appVisual = QX11Info::appVisual();
|
||||
QCOMPARE(appVisual, static_cast<void *>(0));
|
||||
Qt::HANDLE appRootWindow = QX11Info::appRootWindow();
|
||||
QCOMPARE(appRootWindow, static_cast<Qt::HANDLE>(0));
|
||||
|
||||
bool appDefaultColormap = QX11Info::appDefaultColormap();
|
||||
QCOMPARE(appDefaultColormap, true);
|
||||
bool appDefaultVisual = QX11Info::appDefaultVisual();
|
||||
QCOMPARE(appDefaultVisual, true);
|
||||
|
||||
int appDpiX = QX11Info::appDpiX();
|
||||
int appDpiY = QX11Info::appDpiY();
|
||||
QCOMPARE(appDpiX, 75);
|
||||
QCOMPARE(appDpiY, 75);
|
||||
|
||||
// the setAppDpi{X,Y} calls do nothing if QApplication hasn't been
|
||||
// constructed
|
||||
QX11Info::setAppDpiX(-1, 120);
|
||||
QX11Info::setAppDpiY(-1, 120);
|
||||
appDpiX = QX11Info::appDpiX();
|
||||
appDpiY = QX11Info::appDpiY();
|
||||
QCOMPARE(appDpiX, 75);
|
||||
QCOMPARE(appDpiY, 75);
|
||||
|
||||
unsigned long appTime = QX11Info::appTime();
|
||||
unsigned long appUserTime = QX11Info::appUserTime();
|
||||
QCOMPARE(appTime, 0ul);
|
||||
QCOMPARE(appTime, 0ul);
|
||||
// setApp*Time do nothing without QApplication
|
||||
QX11Info::setAppTime(1234);
|
||||
QX11Info::setAppUserTime(5678);
|
||||
appTime = QX11Info::appTime();
|
||||
appUserTime = QX11Info::appUserTime();
|
||||
QCOMPARE(appTime, 0ul);
|
||||
QCOMPARE(appTime, 0ul);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QX11Info)
|
||||
#include "tst_qx11info.moc"
|
Loading…
Reference in New Issue
Block a user