remove Qt/Embedded.
Everybody use Lighhouse instead :)
This commit is contained in:
parent
6ac7f6afd0
commit
88e39d8654
@ -1,567 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
#include <private/qabstractprintdialog_p.h>
|
||||
#include "qprintdialog.h"
|
||||
|
||||
#ifndef QT_NO_PRINTDIALOG
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qbuttongroup.h"
|
||||
#include "qradiobutton.h"
|
||||
#include "qcombobox.h"
|
||||
#include "qspinbox.h"
|
||||
#include "qprinter.h"
|
||||
#include "qlineedit.h"
|
||||
#include "qdir.h"
|
||||
#include "qmessagebox.h"
|
||||
#include "qinputdialog.h"
|
||||
#include "qlayout.h"
|
||||
#include "qlabel.h"
|
||||
|
||||
#include "qlibrary.h"
|
||||
|
||||
#ifndef QT_NO_NIS
|
||||
|
||||
#ifndef BOOL_DEFINED
|
||||
#define BOOL_DEFINED
|
||||
#endif
|
||||
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
|
||||
#endif //QT_NO_NIS
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef void (*QPrintDialogCreator)(QPrintDialog *parent);
|
||||
Q_GUI_EXPORT QPrintDialogCreator _qt_print_dialog_creator;
|
||||
|
||||
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QPrintDialog)
|
||||
public:
|
||||
QButtonGroup *printerOrFile;
|
||||
bool outputToFile;
|
||||
QRadioButton *printToPrinterButton;
|
||||
QRadioButton *printToFileButton;
|
||||
QLineEdit *fileName;
|
||||
|
||||
QButtonGroup *colorMode;
|
||||
QRadioButton *printColor;
|
||||
QRadioButton *printGray;
|
||||
QPrinter::ColorMode colorMode2;
|
||||
|
||||
QComboBox *orientationCombo, *sizeCombo;
|
||||
QPrinter::PaperSize pageSize;
|
||||
QPrinter::Orientation orientation;
|
||||
|
||||
QSpinBox *copies;
|
||||
int numCopies;
|
||||
QPrinter::PaperSize indexToPaperSize[QPrinter::NPaperSize];
|
||||
|
||||
QComboBox *rangeCombo;
|
||||
QSpinBox *firstPage;
|
||||
QSpinBox *lastPage;
|
||||
|
||||
QComboBox *pageOrderCombo;
|
||||
QPrinter::PageOrder pageOrder2;
|
||||
|
||||
QString faxNum;
|
||||
|
||||
void init();
|
||||
|
||||
void _q_okClicked();
|
||||
void _q_printerOrFileSelected(QAbstractButton *b);
|
||||
void _q_paperSizeSelected(int);
|
||||
void _q_orientSelected(int);
|
||||
void _q_pageOrderSelected(int);
|
||||
void _q_colorModeSelected(QAbstractButton *);
|
||||
void _q_setNumCopies(int);
|
||||
void _q_printRangeSelected(int);
|
||||
void _q_setFirstPage(int);
|
||||
void _q_setLastPage(int);
|
||||
void _q_fileNameEditChanged(const QString &text);
|
||||
|
||||
void setupDestination();
|
||||
void setupPrinterSettings();
|
||||
void setupPaper();
|
||||
void setupOptions();
|
||||
|
||||
void setPrinter(QPrinter *p, bool pickUpSettings);
|
||||
};
|
||||
|
||||
static void isc(QPrintDialogPrivate *d, const QString & text,
|
||||
QPrinter::PaperSize ps);
|
||||
|
||||
void QPrintDialogPrivate::_q_okClicked()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
#ifndef QT_NO_MESSAGEBOX
|
||||
if (outputToFile && fileName->isModified() && QFileInfo(fileName->text()).exists()) {
|
||||
int confirm = QMessageBox::warning(
|
||||
q, QPrintDialog::tr("File exists"),
|
||||
QPrintDialog::tr("<qt>Do you want to overwrite it?</qt>"),
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (confirm == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
#endif // QT_NO_MESSAGEBOX
|
||||
|
||||
lastPage->interpretText();
|
||||
firstPage->interpretText();
|
||||
copies->interpretText();
|
||||
if (outputToFile) {
|
||||
printer->setOutputFileName(fileName->text());
|
||||
}
|
||||
printer->setOrientation(orientation);
|
||||
printer->setPaperSize(pageSize);
|
||||
printer->setPageOrder(pageOrder2);
|
||||
printer->setColorMode(colorMode2);
|
||||
printer->setCopyCount(numCopies);
|
||||
|
||||
switch ((rangeCombo->itemData(rangeCombo->currentIndex())).toInt()){
|
||||
case (int)QPrintDialog::AllPages:
|
||||
q->setPrintRange(QPrintDialog::AllPages);
|
||||
q->setFromTo(0, 0);
|
||||
break;
|
||||
case (int)QPrintDialog::Selection:
|
||||
q->setPrintRange(QPrintDialog::Selection);
|
||||
q->setFromTo(0, 0);
|
||||
break;
|
||||
case (int)QPrintDialog::PageRange:
|
||||
q->setPrintRange(QPrintDialog::PageRange);
|
||||
q->setFromTo(firstPage->value(), lastPage->value());
|
||||
break;
|
||||
case (int)QPrintDialog::CurrentPage:
|
||||
q->setPrintRange(QPrintDialog::CurrentPage);
|
||||
q->setFromTo(0, 0);
|
||||
break;
|
||||
}
|
||||
q->accept();
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_printerOrFileSelected(QAbstractButton *b)
|
||||
{
|
||||
outputToFile = (b == printToFileButton);
|
||||
if (outputToFile) {
|
||||
_q_fileNameEditChanged(fileName->text());
|
||||
if (!fileName->isModified() && fileName->text().isEmpty()) {
|
||||
QString file = "print.tiff";
|
||||
fileName->setText(file);
|
||||
fileName->setCursorPosition(file.length());
|
||||
fileName->selectAll();
|
||||
fileName->setModified(true); // confirm overwrite when OK clicked
|
||||
|
||||
}
|
||||
fileName->setEnabled(true);
|
||||
fileName->setFocus();
|
||||
} else {
|
||||
fileName->setText(QString());
|
||||
if (fileName->isEnabled())
|
||||
fileName->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_paperSizeSelected(int id)
|
||||
{
|
||||
if (id < QPrinter::NPaperSize)
|
||||
pageSize = QPrinter::PaperSize(indexToPaperSize[id]);
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_orientSelected(int id)
|
||||
{
|
||||
orientation = (QPrinter::Orientation)id;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_pageOrderSelected(int id)
|
||||
{
|
||||
pageOrder2 = (QPrinter::PageOrder)id;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_colorModeSelected(QAbstractButton *b)
|
||||
{
|
||||
colorMode2 = (b == printColor) ? QPrinter::Color : QPrinter::GrayScale;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_setNumCopies(int copies)
|
||||
{
|
||||
numCopies = copies;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_printRangeSelected(int id)
|
||||
{
|
||||
bool enable = (rangeCombo->itemData(id).toInt() == (int)QPrintDialog::PageRange);
|
||||
firstPage->setEnabled(enable);
|
||||
lastPage->setEnabled(enable);
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_setFirstPage(int fp)
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
if (printer) {
|
||||
lastPage->setMinimum(fp);
|
||||
lastPage->setMaximum(qMax(fp, q->maxPage()));
|
||||
}
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_setLastPage(int lp)
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
if (printer) {
|
||||
firstPage->setMinimum(qMin(lp, q->minPage()));
|
||||
firstPage->setMaximum(lp);
|
||||
}
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::_q_fileNameEditChanged(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text);
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setupDestination()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
|
||||
// print destinations
|
||||
printerOrFile = new QButtonGroup(q);
|
||||
QObject::connect(printerOrFile, SIGNAL(buttonClicked(QAbstractButton*)),
|
||||
q, SLOT(_q_printerOrFileSelected(QAbstractButton*)));
|
||||
|
||||
printToPrinterButton = q->findChild<QRadioButton *>("printToPrinterButton");
|
||||
printerOrFile->addButton(printToPrinterButton);
|
||||
printToFileButton = q->findChild<QRadioButton *>("printToFileButton");
|
||||
printerOrFile->addButton(printToFileButton);
|
||||
|
||||
// file name
|
||||
fileName = q->findChild<QLineEdit *>("fileName");
|
||||
QObject::connect(fileName, SIGNAL(textChanged(QString)),
|
||||
q, SLOT(_q_fileNameEditChanged(QString)));
|
||||
|
||||
outputToFile = false;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setupPrinterSettings()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
|
||||
// color mode
|
||||
colorMode = new QButtonGroup(q);
|
||||
QObject::connect(colorMode, SIGNAL(buttonClicked(QAbstractButton*)),
|
||||
q, SLOT(_q_colorModeSelected(QAbstractButton*)));
|
||||
|
||||
printColor = q->findChild<QRadioButton *>("printColor");
|
||||
colorMode->addButton(printColor);
|
||||
printGray = q->findChild<QRadioButton *>("printGray");
|
||||
colorMode->addButton(printGray);
|
||||
}
|
||||
|
||||
void isc(QPrintDialogPrivate *ptr, const QString & text, QPrinter::PaperSize ps)
|
||||
{
|
||||
if (ptr && !text.isEmpty() && ps < QPrinter::NPaperSize) {
|
||||
ptr->sizeCombo->addItem(text);
|
||||
int index = ptr->sizeCombo->count()-1;
|
||||
if (index >= 0 && index < QPrinter::NPaperSize)
|
||||
ptr->indexToPaperSize[index] = ps;
|
||||
}
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setupPaper()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
|
||||
pageSize = QPrinter::A4;
|
||||
|
||||
// paper orientation
|
||||
orientationCombo = q->findChild<QComboBox *>("orientationCombo");
|
||||
orientation = QPrinter::Portrait;
|
||||
QObject::connect(orientationCombo, SIGNAL(activated(int)),
|
||||
q, SLOT(_q_orientSelected(int)));
|
||||
|
||||
// paper size
|
||||
sizeCombo = q->findChild<QComboBox *>("sizeCombo");
|
||||
|
||||
int n;
|
||||
for(n=0; n<QPrinter::NPaperSize; n++)
|
||||
indexToPaperSize[n] = QPrinter::A4;
|
||||
|
||||
isc(this, QPrintDialog::tr("A0 (841 x 1189 mm)"), QPrinter::A0);
|
||||
isc(this, QPrintDialog::tr("A1 (594 x 841 mm)"), QPrinter::A1);
|
||||
isc(this, QPrintDialog::tr("A2 (420 x 594 mm)"), QPrinter::A2);
|
||||
isc(this, QPrintDialog::tr("A3 (297 x 420 mm)"), QPrinter::A3);
|
||||
isc(this, QPrintDialog::tr("A4 (210 x 297 mm, 8.26 x 11.7 inches)"), QPrinter::A4);
|
||||
isc(this, QPrintDialog::tr("A5 (148 x 210 mm)"), QPrinter::A5);
|
||||
isc(this, QPrintDialog::tr("A6 (105 x 148 mm)"), QPrinter::A6);
|
||||
isc(this, QPrintDialog::tr("A7 (74 x 105 mm)"), QPrinter::A7);
|
||||
isc(this, QPrintDialog::tr("A8 (52 x 74 mm)"), QPrinter::A8);
|
||||
isc(this, QPrintDialog::tr("A9 (37 x 52 mm)"), QPrinter::A9);
|
||||
isc(this, QPrintDialog::tr("B0 (1000 x 1414 mm)"), QPrinter::B0);
|
||||
isc(this, QPrintDialog::tr("B1 (707 x 1000 mm)"), QPrinter::B1);
|
||||
isc(this, QPrintDialog::tr("B2 (500 x 707 mm)"), QPrinter::B2);
|
||||
isc(this, QPrintDialog::tr("B3 (353 x 500 mm)"), QPrinter::B3);
|
||||
isc(this, QPrintDialog::tr("B4 (250 x 353 mm)"), QPrinter::B4);
|
||||
isc(this, QPrintDialog::tr("B5 (176 x 250 mm, 6.93 x 9.84 inches)"), QPrinter::B5);
|
||||
isc(this, QPrintDialog::tr("B6 (125 x 176 mm)"), QPrinter::B6);
|
||||
isc(this, QPrintDialog::tr("B7 (88 x 125 mm)"), QPrinter::B7);
|
||||
isc(this, QPrintDialog::tr("B8 (62 x 88 mm)"), QPrinter::B8);
|
||||
isc(this, QPrintDialog::tr("B9 (44 x 62 mm)"), QPrinter::B9);
|
||||
isc(this, QPrintDialog::tr("B10 (31 x 44 mm)"), QPrinter::B10);
|
||||
isc(this, QPrintDialog::tr("C5E (163 x 229 mm)"), QPrinter::C5E);
|
||||
isc(this, QPrintDialog::tr("DLE (110 x 220 mm)"), QPrinter::DLE);
|
||||
isc(this, QPrintDialog::tr("Executive (7.5 x 10 inches, 191 x 254 mm)"), QPrinter::Executive);
|
||||
isc(this, QPrintDialog::tr("Folio (210 x 330 mm)"), QPrinter::Folio);
|
||||
isc(this, QPrintDialog::tr("Ledger (432 x 279 mm)"), QPrinter::Ledger);
|
||||
isc(this, QPrintDialog::tr("Legal (8.5 x 14 inches, 216 x 356 mm)"), QPrinter::Legal);
|
||||
isc(this, QPrintDialog::tr("Letter (8.5 x 11 inches, 216 x 279 mm)"), QPrinter::Letter);
|
||||
isc(this, QPrintDialog::tr("Tabloid (279 x 432 mm)"), QPrinter::Tabloid);
|
||||
isc(this, QPrintDialog::tr("US Common #10 Envelope (105 x 241 mm)"), QPrinter::Comm10E);
|
||||
|
||||
QObject::connect(sizeCombo, SIGNAL(activated(int)),
|
||||
q, SLOT(_q_paperSizeSelected(int)));
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setupOptions()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
|
||||
// no. of copies
|
||||
copies = q->findChild<QSpinBox *>("copies");
|
||||
QObject::connect(copies, SIGNAL(valueChanged(int)),
|
||||
q, SLOT(_q_setNumCopies(int)));
|
||||
|
||||
// print range
|
||||
rangeCombo = q->findChild<QComboBox *>("rangeCombo");
|
||||
rangeCombo->addItem(QPrintDialog::tr("Print all"), QPrintDialog::AllPages);
|
||||
rangeCombo->addItem(QPrintDialog::tr("Print selection"), QPrintDialog::Selection);
|
||||
rangeCombo->addItem(QPrintDialog::tr("Print range"), QPrintDialog::PageRange);
|
||||
rangeCombo->addItem(QPrintDialog::tr("Print current page"), QPrintDialog::CurrentPage);
|
||||
QObject::connect(rangeCombo, SIGNAL(activated(int)),
|
||||
q, SLOT(_q_printRangeSelected(int)));
|
||||
|
||||
// page range
|
||||
firstPage = q->findChild<QSpinBox *>("firstPage");
|
||||
firstPage->setRange(1, 9999);
|
||||
firstPage->setValue(1);
|
||||
QObject::connect(firstPage, SIGNAL(valueChanged(int)),
|
||||
q, SLOT(_q_setFirstPage(int)));
|
||||
|
||||
lastPage = q->findChild<QSpinBox *>("lastPage");
|
||||
lastPage->setRange(1, 9999);
|
||||
lastPage->setValue(1);
|
||||
QObject::connect(lastPage, SIGNAL(valueChanged(int)),
|
||||
q, SLOT(_q_setLastPage(int)));
|
||||
|
||||
// print order
|
||||
pageOrderCombo = q->findChild<QComboBox *>("pageOrderCombo");
|
||||
QObject::connect(pageOrderCombo, SIGNAL(activated(int)),
|
||||
q, SLOT(_q_pageOrderSelected(int)));
|
||||
}
|
||||
|
||||
bool QPrintDialog::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
Q_UNUSED(o);
|
||||
|
||||
Q_D(QPrintDialog);
|
||||
switch (e->type()){
|
||||
case QEvent::KeyPress:
|
||||
switch (static_cast<QKeyEvent*>(e)->key()) {
|
||||
case Qt::Key_Back:
|
||||
d->_q_okClicked();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
|
||||
: QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
|
||||
{
|
||||
d_func()->init();
|
||||
}
|
||||
|
||||
QPrintDialog::QPrintDialog(QWidget *parent)
|
||||
: QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)
|
||||
{
|
||||
d_func()->init();
|
||||
}
|
||||
|
||||
QPrintDialog::~QPrintDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setPrinter(QPrinter *p, bool pickUpSettings)
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
printer = p;
|
||||
|
||||
if (p && pickUpSettings) {
|
||||
// top to bottom in the old dialog.
|
||||
// printer or file
|
||||
outputToFile = !p->outputFileName().isEmpty() && q->isOptionEnabled(QPrintDialog::PrintToFile);
|
||||
if (outputToFile)
|
||||
printToFileButton->setChecked(true);
|
||||
else
|
||||
printToPrinterButton->setChecked(true);
|
||||
fileName->setEnabled(outputToFile);
|
||||
|
||||
// file name
|
||||
if (q->isOptionEnabled(QPrintDialog::PrintToFile)) {
|
||||
fileName->setText(p->outputFileName());
|
||||
fileName->setModified(!fileName->text().isEmpty());
|
||||
} else {
|
||||
printToFileButton->setEnabled(false);
|
||||
}
|
||||
|
||||
// orientation
|
||||
orientationCombo->setCurrentIndex((int)p->orientation());
|
||||
_q_orientSelected(p->orientation());
|
||||
|
||||
// page size
|
||||
int n = 0;
|
||||
while (n < QPrinter::NPaperSize &&
|
||||
indexToPaperSize[n] != p->pageSize())
|
||||
n++;
|
||||
sizeCombo->setCurrentIndex(n);
|
||||
_q_paperSizeSelected(n);
|
||||
|
||||
// page order
|
||||
pageOrder2 = p->pageOrder();
|
||||
pageOrderCombo->setCurrentIndex((int)pageOrder2);
|
||||
|
||||
// color mode
|
||||
colorMode2 = p->colorMode();
|
||||
if (colorMode2 == QPrinter::Color)
|
||||
printColor->setChecked(true);
|
||||
else
|
||||
printGray->setChecked(true);
|
||||
|
||||
// number of copies
|
||||
copies->setValue(p->copyCount());
|
||||
_q_setNumCopies(p->copyCount());
|
||||
}
|
||||
|
||||
if (p) {
|
||||
if (!q->isOptionEnabled(QPrintDialog::PrintSelection)
|
||||
&& rangeCombo->findData(QPrintDialog::Selection) > 0)
|
||||
rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::Selection));
|
||||
if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
|
||||
&& rangeCombo->findData(QPrintDialog::PageRange) > 0)
|
||||
rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::PageRange));
|
||||
if (!q->isOptionEnabled(QPrintDialog::PrintCurrentPage)
|
||||
&& rangeCombo->findData(QPrintDialog::CurrentPage) > 0)
|
||||
rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::CurrentPage));
|
||||
|
||||
switch (q->printRange()) {
|
||||
case QPrintDialog::AllPages:
|
||||
rangeCombo->setCurrentIndex((int)(QPrintDialog::AllPages));
|
||||
break;
|
||||
case QPrintDialog::Selection:
|
||||
rangeCombo->setCurrentIndex((int)(QPrintDialog::Selection));
|
||||
break;
|
||||
case QPrintDialog::PageRange:
|
||||
rangeCombo->setCurrentIndex((int)(QPrintDialog::PageRange));
|
||||
break;
|
||||
case QPrintDialog::CurrentPage:
|
||||
rangeCombo->setCurrentIndex((int)(QPrintDialog::CurrentPage));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p && q->maxPage()) {
|
||||
int from = q->minPage();
|
||||
int to = q->maxPage();
|
||||
if (q->printRange() == QPrintDialog::PageRange) {
|
||||
from = q->fromPage();
|
||||
to = q->toPage();
|
||||
}
|
||||
firstPage->setRange(q->minPage(), to);
|
||||
lastPage->setRange(from, q->maxPage());
|
||||
firstPage->setValue(from);
|
||||
lastPage->setValue(to);
|
||||
}
|
||||
}
|
||||
|
||||
int QPrintDialog::exec()
|
||||
{
|
||||
Q_D(QPrintDialog);
|
||||
d->setPrinter(d->printer, true);
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::init()
|
||||
{
|
||||
Q_Q(QPrintDialog);
|
||||
numCopies = 1;
|
||||
|
||||
if (_qt_print_dialog_creator)
|
||||
(*_qt_print_dialog_creator)(q);
|
||||
|
||||
setupDestination();
|
||||
setupPrinterSettings();
|
||||
setupPaper();
|
||||
setupOptions();
|
||||
|
||||
setPrinter(printer, true);
|
||||
|
||||
q->installEventFilter(q);
|
||||
}
|
||||
|
||||
void QPrintDialog::setVisible(bool visible)
|
||||
{
|
||||
QAbstractPrintDialog::setVisible(visible);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qprintdialog.cpp"
|
||||
#include "qrc_qprintdialog.cpp"
|
||||
|
||||
#endif // QT_NO_PRINTDIALOG
|
@ -1,114 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui/qpaintdevice.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
|
||||
#include "qegl_p.h"
|
||||
#include "qeglcontext_p.h"
|
||||
|
||||
#if !defined(QT_NO_EGL)
|
||||
|
||||
#include <qscreen_qws.h>
|
||||
#include <qscreenproxy_qws.h>
|
||||
#include <qapplication.h>
|
||||
#include <qdesktopwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QScreen *screenForDevice(QPaintDevice *device)
|
||||
{
|
||||
QScreen *screen = qt_screen;
|
||||
if (!screen)
|
||||
return 0;
|
||||
if (screen->classId() == QScreen::MultiClass) {
|
||||
int screenNumber;
|
||||
if (device && device->devType() == QInternal::Widget)
|
||||
screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
|
||||
else
|
||||
screenNumber = 0;
|
||||
screen = screen->subScreens()[screenNumber];
|
||||
}
|
||||
while (screen->classId() == QScreen::ProxyClass ||
|
||||
screen->classId() == QScreen::TransformedClass) {
|
||||
screen = static_cast<QProxyScreen *>(screen)->screen();
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
// Set pixel format and other properties based on a paint device.
|
||||
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
// Find the QGLScreen for this paint device.
|
||||
QScreen *screen = screenForDevice(dev);
|
||||
if (!screen)
|
||||
return;
|
||||
int devType = dev->devType();
|
||||
if (devType == QInternal::Image)
|
||||
setPixelFormat(static_cast<QImage *>(dev)->format());
|
||||
else
|
||||
setPixelFormat(screen->pixelFormat());
|
||||
}
|
||||
|
||||
EGLNativeDisplayType QEgl::nativeDisplay()
|
||||
{
|
||||
return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
|
||||
{
|
||||
return (EGLNativeWindowType)(widget->winId()); // Might work
|
||||
}
|
||||
|
||||
EGLNativePixmapType QEgl::nativePixmap(QPixmap*)
|
||||
{
|
||||
qWarning("QEgl: EGL pixmap surfaces not supported on QWS");
|
||||
return (EGLNativePixmapType)0;
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // !QT_NO_EGL
|
@ -1,608 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcopchannel_qws.h"
|
||||
|
||||
#ifndef QT_NO_COP
|
||||
|
||||
#include "qwsdisplay_qws.h"
|
||||
#include "qwscommand_qws_p.h"
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qwindowsystem_p.h"
|
||||
#include "qlist.h"
|
||||
#include "qmap.h"
|
||||
#include "qdatastream.h"
|
||||
#include "qpointer.h"
|
||||
#include "qmutex.h"
|
||||
|
||||
#include "qdebug.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QMap<QString, QList<QWSClient*> > QCopServerMap;
|
||||
static QCopServerMap *qcopServerMap = 0;
|
||||
|
||||
class QCopServerRegexp
|
||||
{
|
||||
public:
|
||||
QCopServerRegexp( const QString& channel, QWSClient *client );
|
||||
QCopServerRegexp( const QCopServerRegexp& other );
|
||||
|
||||
QString channel;
|
||||
QWSClient *client;
|
||||
QRegExp regexp;
|
||||
};
|
||||
|
||||
QCopServerRegexp::QCopServerRegexp( const QString& channel, QWSClient *client )
|
||||
{
|
||||
this->channel = channel;
|
||||
this->client = client;
|
||||
this->regexp = QRegExp( channel, Qt::CaseSensitive, QRegExp::Wildcard );
|
||||
}
|
||||
|
||||
QCopServerRegexp::QCopServerRegexp( const QCopServerRegexp& other )
|
||||
{
|
||||
channel = other.channel;
|
||||
client = other.client;
|
||||
regexp = other.regexp;
|
||||
}
|
||||
|
||||
typedef QList<QCopServerRegexp> QCopServerRegexpList;
|
||||
static QCopServerRegexpList *qcopServerRegexpList = 0;
|
||||
|
||||
typedef QMap<QString, QList< QPointer<QCopChannel> > > QCopClientMap;
|
||||
static QCopClientMap *qcopClientMap = 0;
|
||||
|
||||
Q_GLOBAL_STATIC(QMutex, qcopClientMapMutex)
|
||||
|
||||
// Determine if a channel name contains wildcard characters.
|
||||
static bool containsWildcards( const QString& channel )
|
||||
{
|
||||
return channel.contains(QLatin1Char('*'));
|
||||
}
|
||||
|
||||
class QCopChannelPrivate
|
||||
{
|
||||
public:
|
||||
QString channel;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QCopChannel
|
||||
\ingroup qws
|
||||
|
||||
\brief The QCopChannel class provides communication capabilities
|
||||
between clients in \l{Qt for Embedded Linux}.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
The Qt COmmunication Protocol (QCOP) is a many-to-many protocol
|
||||
for transferring messages across registered channels. A channel is
|
||||
registered by name, and anyone who wants to can listen to the
|
||||
channel as well as send messages through it. The QCOP protocol
|
||||
allows clients to communicate both within the same address space
|
||||
and between different processes.
|
||||
|
||||
To send messages to a given channel, QCopChannel provides the
|
||||
static send() function. Using this function alone, the messages
|
||||
are queued until Qt re-enters the event loop. To immediately flush
|
||||
all queued messages to the registered listeners, call the static
|
||||
flush() function.
|
||||
|
||||
To listen to the traffic on a given channel, you typically
|
||||
instantiate a QCopChannel object for the given channel and connect
|
||||
to its received() signal that is emitted whenever there is
|
||||
incoming data. Use the static isRegistered() function to query
|
||||
the server for the existence of a given channel. QCopChannel
|
||||
provides the channel() function returning the name of this
|
||||
QCopChannel object's channel.
|
||||
|
||||
In additon, QCopChannel provides the virtual receive() function
|
||||
that can be reimplemented to filter the incoming messages and
|
||||
data. The default implementation simply emits the received()
|
||||
signal.
|
||||
|
||||
\sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QCopChannel object for the specified \a channel, with
|
||||
the given \a parent. Once created, the channel is registered by
|
||||
the server.
|
||||
|
||||
\sa isRegistered(), channel()
|
||||
*/
|
||||
|
||||
QCopChannel::QCopChannel(const QString& channel, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
init(channel);
|
||||
}
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
/*!
|
||||
Use the two argument overload instead, and call the
|
||||
QObject::setObjectName() function to \a name the instance.
|
||||
*/
|
||||
QCopChannel::QCopChannel(const QString& channel, QObject *parent, const char *name) :
|
||||
QObject(parent)
|
||||
{
|
||||
setObjectName(QString::fromAscii(name));
|
||||
init(channel);
|
||||
}
|
||||
#endif
|
||||
|
||||
void QCopChannel::init(const QString& channel)
|
||||
{
|
||||
d = new QCopChannelPrivate;
|
||||
d->channel = channel;
|
||||
|
||||
if (!qt_fbdpy) {
|
||||
qFatal("QCopChannel: Must construct a QApplication "
|
||||
"before QCopChannel");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
QMutexLocker locker(qcopClientMapMutex());
|
||||
|
||||
if (!qcopClientMap)
|
||||
qcopClientMap = new QCopClientMap;
|
||||
|
||||
// do we need a new channel list ?
|
||||
QCopClientMap::Iterator it = qcopClientMap->find(channel);
|
||||
if (it != qcopClientMap->end()) {
|
||||
it.value().append(this);
|
||||
return;
|
||||
}
|
||||
|
||||
it = qcopClientMap->insert(channel, QList< QPointer<QCopChannel> >());
|
||||
it.value().append(QPointer<QCopChannel>(this));
|
||||
}
|
||||
|
||||
// inform server about this channel
|
||||
qt_fbdpy->registerChannel(channel);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Resend all channel registrations
|
||||
*/
|
||||
void QCopChannel::reregisterAll()
|
||||
{
|
||||
if(qcopClientMap)
|
||||
for(QCopClientMap::Iterator iter = qcopClientMap->begin();
|
||||
iter != qcopClientMap->end();
|
||||
++iter)
|
||||
qt_fbdpy->registerChannel(iter.key());
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QCopChannel object.
|
||||
|
||||
The server is notified that this particular listener has closed
|
||||
its connection. The server will keep the channel open until the
|
||||
last registered listener detaches.
|
||||
|
||||
\sa isRegistered(), channel()
|
||||
*/
|
||||
|
||||
QCopChannel::~QCopChannel()
|
||||
{
|
||||
QMutexLocker locker(qcopClientMapMutex());
|
||||
QCopClientMap::Iterator it = qcopClientMap->find(d->channel);
|
||||
Q_ASSERT(it != qcopClientMap->end());
|
||||
it.value().removeAll(this);
|
||||
// still any clients connected locally ?
|
||||
if (it.value().isEmpty()) {
|
||||
QByteArray data;
|
||||
QDataStream s(&data, QIODevice::WriteOnly);
|
||||
s << d->channel;
|
||||
if (qt_fbdpy)
|
||||
send(QLatin1String(""), QLatin1String("detach()"), data);
|
||||
qcopClientMap->remove(d->channel);
|
||||
}
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the name of this object's channel.
|
||||
|
||||
\sa isRegistered()
|
||||
*/
|
||||
|
||||
QString QCopChannel::channel() const
|
||||
{
|
||||
return d->channel;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QCopChannel::receive(const QString& message, const QByteArray &data)
|
||||
|
||||
Processes the incoming \a message and \a data.
|
||||
|
||||
This function is called by the server when this object's channel
|
||||
receives new messages. Note that the default implementation simply
|
||||
emits the received() signal; reimplement this function to process
|
||||
the incoming \a message and \a data.
|
||||
|
||||
Note that the format of the given \a data has to be well defined
|
||||
in order to extract the information it contains. In addition, it
|
||||
is recommended to use the DCOP convention. This is not a
|
||||
requirement, but you must ensure that the sender and receiver
|
||||
agree on the argument types. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp 0
|
||||
|
||||
The above code assumes that the \c message is a DCOP-style
|
||||
function signature and the \c data contains the function's
|
||||
arguments.
|
||||
|
||||
\sa send(), channel(), received()
|
||||
*/
|
||||
void QCopChannel::receive(const QString& msg, const QByteArray &data)
|
||||
{
|
||||
emit received(msg, data);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QCopChannel::received(const QString& message, const QByteArray &data)
|
||||
|
||||
This signal is emitted whenever this object's channel receives new
|
||||
messages (i.e., it is emitted by the receive() function), passing
|
||||
the incoming \a message and \a data as parameters.
|
||||
|
||||
\sa receive(), channel()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Queries the server for the existence of the given \a channel. Returns true
|
||||
if the channel is registered; otherwise returns false.
|
||||
|
||||
\sa channel(), send()
|
||||
*/
|
||||
|
||||
bool QCopChannel::isRegistered(const QString& channel)
|
||||
{
|
||||
QByteArray data;
|
||||
QDataStream s(&data, QIODevice::WriteOnly);
|
||||
s << channel;
|
||||
if (!send(QLatin1String(""), QLatin1String("isRegistered()"), data))
|
||||
return false;
|
||||
|
||||
QWSQCopMessageEvent *e = qt_fbdpy->waitForQCopResponse();
|
||||
bool known = e->message == "known";
|
||||
delete e;
|
||||
return known;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QCopChannel::send(const QString& channel, const QString& message)
|
||||
\overload
|
||||
*/
|
||||
|
||||
bool QCopChannel::send(const QString& channel, const QString& msg)
|
||||
{
|
||||
QByteArray data;
|
||||
return send(channel, msg, data);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QCopChannel::send(const QString& channel, const QString& message,
|
||||
const QByteArray &data)
|
||||
|
||||
Sends the given \a message on the specified \a channel with the
|
||||
given \a data. The message will be distributed to all clients
|
||||
subscribed to the channel. Returns true if the message is sent
|
||||
successfully; otherwise returns false.
|
||||
|
||||
It is recommended to use the DCOP convention. This is not a
|
||||
requirement, but you must ensure that the sender and receiver
|
||||
agree on the argument types.
|
||||
|
||||
Note that QDataStream provides a convenient way to fill the byte
|
||||
array with auxiliary data. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp 1
|
||||
|
||||
In the code above the channel is \c "System/Shell". The \c message
|
||||
is an arbitrary string, but in the example we've used the DCOP
|
||||
convention of passing a function signature. Such a signature is
|
||||
formatted as \c "functionname(types)" where \c types is a list of
|
||||
zero or more comma-separated type names, with no whitespace, no
|
||||
consts and no pointer or reference marks, i.e. no "*" or "&".
|
||||
|
||||
\sa receive(), isRegistered()
|
||||
*/
|
||||
|
||||
bool QCopChannel::send(const QString& channel, const QString& msg,
|
||||
const QByteArray &data)
|
||||
{
|
||||
if (!qt_fbdpy) {
|
||||
qFatal("QCopChannel::send: Must construct a QApplication "
|
||||
"before using QCopChannel");
|
||||
return false;
|
||||
}
|
||||
|
||||
qt_fbdpy->sendMessage(channel, msg, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Flushes all queued messages to the registered listeners.
|
||||
|
||||
Note that this function returns false if no QApplication has been
|
||||
constructed, otherwise it returns true.
|
||||
|
||||
\sa send()
|
||||
|
||||
*/
|
||||
bool QCopChannel::flush()
|
||||
{
|
||||
if (!qt_fbdpy) {
|
||||
qFatal("QCopChannel::flush: Must construct a QApplication "
|
||||
"before using QCopChannel");
|
||||
return false;
|
||||
}
|
||||
|
||||
qt_fbdpy->flushCommands();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class QWSServerSignalBridge : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void emitNewChannel(const QString& channel);
|
||||
void emitRemovedChannel(const QString& channel);
|
||||
|
||||
signals:
|
||||
void newChannel(const QString& channel);
|
||||
void removedChannel(const QString& channel);
|
||||
};
|
||||
|
||||
void QWSServerSignalBridge::emitNewChannel(const QString& channel){
|
||||
emit newChannel(channel);
|
||||
}
|
||||
|
||||
void QWSServerSignalBridge::emitRemovedChannel(const QString& channel) {
|
||||
emit removedChannel(channel);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Server side: subscribe client \a cl on channel \a ch.
|
||||
*/
|
||||
|
||||
void QCopChannel::registerChannel(const QString& ch, QWSClient *cl)
|
||||
{
|
||||
if (!qcopServerMap)
|
||||
qcopServerMap = new QCopServerMap;
|
||||
|
||||
// do we need a new channel list ?
|
||||
QCopServerMap::Iterator it = qcopServerMap->find(ch);
|
||||
if (it == qcopServerMap->end())
|
||||
it = qcopServerMap->insert(ch, QList<QWSClient*>());
|
||||
|
||||
// If the channel name contains wildcard characters, then we also
|
||||
// register it on the server regexp matching list.
|
||||
if (containsWildcards( ch )) {
|
||||
QCopServerRegexp item(ch, cl);
|
||||
if (!qcopServerRegexpList)
|
||||
qcopServerRegexpList = new QCopServerRegexpList;
|
||||
qcopServerRegexpList->append( item );
|
||||
}
|
||||
|
||||
// If this is the first client in the channel, announce the channel as being created.
|
||||
if (it.value().count() == 0) {
|
||||
QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
|
||||
connect(qwsBridge, SIGNAL(newChannel(QString)), qwsServer, SIGNAL(newChannel(QString)));
|
||||
qwsBridge->emitNewChannel(ch);
|
||||
delete qwsBridge;
|
||||
}
|
||||
|
||||
it.value().append(cl);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Server side: unsubscribe \a cl from all channels.
|
||||
*/
|
||||
|
||||
void QCopChannel::detach(QWSClient *cl)
|
||||
{
|
||||
if (!qcopServerMap)
|
||||
return;
|
||||
|
||||
QCopServerMap::Iterator it = qcopServerMap->begin();
|
||||
for (; it != qcopServerMap->end(); ++it) {
|
||||
if (it.value().contains(cl)) {
|
||||
it.value().removeAll(cl);
|
||||
// If this was the last client in the channel, announce the channel as dead.
|
||||
if (it.value().count() == 0) {
|
||||
QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
|
||||
connect(qwsBridge, SIGNAL(removedChannel(QString)), qwsServer, SIGNAL(removedChannel(QString)));
|
||||
qwsBridge->emitRemovedChannel(it.key());
|
||||
delete qwsBridge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!qcopServerRegexpList)
|
||||
return;
|
||||
|
||||
QCopServerRegexpList::Iterator it2 = qcopServerRegexpList->begin();
|
||||
while(it2 != qcopServerRegexpList->end()) {
|
||||
if ((*it2).client == cl)
|
||||
it2 = qcopServerRegexpList->erase(it2);
|
||||
else
|
||||
++it2;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Server side: transmit the message to all clients registered to the
|
||||
specified channel.
|
||||
*/
|
||||
|
||||
void QCopChannel::answer(QWSClient *cl, const QString& ch,
|
||||
const QString& msg, const QByteArray &data)
|
||||
{
|
||||
// internal commands
|
||||
if (ch.isEmpty()) {
|
||||
if (msg == QLatin1String("isRegistered()")) {
|
||||
QString c;
|
||||
QDataStream s(data);
|
||||
s >> c;
|
||||
bool known = qcopServerMap && qcopServerMap->contains(c)
|
||||
&& !((*qcopServerMap)[c]).isEmpty();
|
||||
// Yes, it's a typo, it's not user-visible, and we choose not to fix it for compatibility
|
||||
QLatin1String ans = QLatin1String(known ? "known" : "unknown");
|
||||
QWSServerPrivate::sendQCopEvent(cl, QLatin1String(""),
|
||||
ans, data, true);
|
||||
return;
|
||||
} else if (msg == QLatin1String("detach()")) {
|
||||
QString c;
|
||||
QDataStream s(data);
|
||||
s >> c;
|
||||
Q_ASSERT(qcopServerMap);
|
||||
QCopServerMap::Iterator it = qcopServerMap->find(c);
|
||||
if (it != qcopServerMap->end()) {
|
||||
//Q_ASSERT(it.value().contains(cl));
|
||||
it.value().removeAll(cl);
|
||||
if (it.value().isEmpty()) {
|
||||
// If this was the last client in the channel, announce the channel as dead
|
||||
QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
|
||||
connect(qwsBridge, SIGNAL(removedChannel(QString)), qwsServer, SIGNAL(removedChannel(QString)));
|
||||
qwsBridge->emitRemovedChannel(it.key());
|
||||
delete qwsBridge;
|
||||
qcopServerMap->erase(it);
|
||||
}
|
||||
}
|
||||
if (qcopServerRegexpList && containsWildcards(c)) {
|
||||
// Remove references to a wildcarded channel.
|
||||
QCopServerRegexpList::Iterator it
|
||||
= qcopServerRegexpList->begin();
|
||||
while(it != qcopServerRegexpList->end()) {
|
||||
if ((*it).client == cl && (*it).channel == c)
|
||||
it = qcopServerRegexpList->erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
qWarning("QCopChannel: unknown internal command %s", qPrintable(msg));
|
||||
QWSServerPrivate::sendQCopEvent(cl, QLatin1String(""),
|
||||
QLatin1String("bad"), data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (qcopServerMap) {
|
||||
QList<QWSClient*> clist = qcopServerMap->value(ch);
|
||||
for (int i=0; i < clist.size(); ++i) {
|
||||
QWSClient *c = clist.at(i);
|
||||
QWSServerPrivate::sendQCopEvent(c, ch, msg, data);
|
||||
}
|
||||
}
|
||||
|
||||
if(qcopServerRegexpList && !containsWildcards(ch)) {
|
||||
// Search for wildcard matches and forward the message on.
|
||||
QCopServerRegexpList::ConstIterator it = qcopServerRegexpList->constBegin();
|
||||
for (; it != qcopServerRegexpList->constEnd(); ++it) {
|
||||
if ((*it).regexp.exactMatch(ch)) {
|
||||
QByteArray newData;
|
||||
{
|
||||
QDataStream stream
|
||||
(&newData, QIODevice::WriteOnly | QIODevice::Append);
|
||||
stream << ch;
|
||||
stream << msg;
|
||||
stream << data;
|
||||
// Stream is flushed and closed at this point.
|
||||
}
|
||||
QWSServerPrivate::sendQCopEvent
|
||||
((*it).client, (*it).channel,
|
||||
QLatin1String("forwardedMessage(QString,QString,QByteArray)"),
|
||||
newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Client side: distribute received event to the QCop instance managing the
|
||||
channel.
|
||||
*/
|
||||
void QCopChannel::sendLocally(const QString& ch, const QString& msg,
|
||||
const QByteArray &data)
|
||||
{
|
||||
Q_ASSERT(qcopClientMap);
|
||||
|
||||
// filter out internal events
|
||||
if (ch.isEmpty())
|
||||
return;
|
||||
|
||||
// feed local clients with received data
|
||||
QList< QPointer<QCopChannel> > clients;
|
||||
{
|
||||
QMutexLocker locker(qcopClientMapMutex());
|
||||
clients = (*qcopClientMap)[ch];
|
||||
}
|
||||
for (int i = 0; i < clients.size(); ++i) {
|
||||
QCopChannel *channel = (QCopChannel *)clients.at(i);
|
||||
if ( channel )
|
||||
channel->receive(msg, data);
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qcopchannel_qws.moc"
|
||||
|
||||
#endif
|
@ -1,108 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCOPCHANNEL_QWS_H
|
||||
#define QCOPCHANNEL_QWS_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_COP
|
||||
|
||||
class QWSClient;
|
||||
class QCopChannelPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QCopChannel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QCopChannel(const QString& channel, QObject *parent=0);
|
||||
#ifdef QT3_SUPPORT
|
||||
QT3_SUPPORT_CONSTRUCTOR QCopChannel(const QString& channel, QObject *parent, const char *name);
|
||||
#endif
|
||||
virtual ~QCopChannel();
|
||||
|
||||
QString channel() const;
|
||||
|
||||
static bool isRegistered(const QString& channel);
|
||||
static bool send(const QString& channel, const QString& msg);
|
||||
static bool send(const QString& channel, const QString& msg,
|
||||
const QByteArray &data);
|
||||
|
||||
static bool flush();
|
||||
|
||||
static void sendLocally( const QString& ch, const QString& msg,
|
||||
const QByteArray &data);
|
||||
static void reregisterAll();
|
||||
|
||||
virtual void receive(const QString& msg, const QByteArray &data);
|
||||
|
||||
Q_SIGNALS:
|
||||
void received(const QString& msg, const QByteArray &data);
|
||||
|
||||
private:
|
||||
void init(const QString& channel);
|
||||
|
||||
// server side
|
||||
static void registerChannel(const QString& ch, QWSClient *cl);
|
||||
static void detach(QWSClient *cl);
|
||||
static void answer(QWSClient *cl, const QString& ch,
|
||||
const QString& msg, const QByteArray &data);
|
||||
// client side
|
||||
QCopChannelPrivate* d;
|
||||
|
||||
friend class QWSServer;
|
||||
friend class QWSServerPrivate;
|
||||
friend class QApplication;
|
||||
};
|
||||
|
||||
#endif // QT_NO_COP
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QCOPCHANNEL_QWS_H
|
@ -1,404 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdecoration_qws.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qdrawutil.h"
|
||||
#include "qpainter.h"
|
||||
#include "qregion.h"
|
||||
#include "qwhatsthis.h"
|
||||
|
||||
#include "qmenu.h"
|
||||
#include "private/qwidget_p.h"
|
||||
#include "qwsmanager_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDecoration
|
||||
\ingroup qws
|
||||
|
||||
\brief The QDecoration class is a base class for window
|
||||
decorations in Qt for Embedded Linux
|
||||
|
||||
Note that this class is non-portable and only available in
|
||||
\l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides window management of top level windows
|
||||
and several ready made decorations (i.e., \c Default, \c Styled
|
||||
and \c Windows). Custom decorations can be implemented by
|
||||
subclassing the QDecoration class and creating a decoration plugin
|
||||
(derived from QDecorationPlugin). The default
|
||||
implementation of the QDecorationFactory class will automatically
|
||||
detect the plugin, and load the decoration into the application at
|
||||
run-time using Qt's \l {How to Create Qt Plugins}{plugin
|
||||
system}. To actually apply a decoration, use the
|
||||
QApplication::qwsSetDecoration() function.
|
||||
|
||||
When creating a custom decoration, implement the paint() function
|
||||
to paint the border and title decoration, and the region()
|
||||
function to return the regions the decoration
|
||||
occupies. Reimplement the regionClicked() and
|
||||
regionDoubleClicked() functions to respond to mouse clicks (the
|
||||
default implementations responds to (single) clicks on items in a
|
||||
widget's system menu and double clicks on a widget's title).
|
||||
|
||||
QDecoration provides the DecorationRegion enum that describes the
|
||||
various regions of the window decoration, and the regionAt()
|
||||
function to determine the region containing a given point. The
|
||||
QDecoration class also provides the DecorationState enum
|
||||
describing the state of a given region, e.g. whether it is active
|
||||
or not.
|
||||
|
||||
In addition, it is possible to build the system menu for a given
|
||||
top level widget using the buildSysMenu() function; whenever an
|
||||
action in this menu is triggered, the menuTriggered() function is
|
||||
called automatically.
|
||||
|
||||
Finally, the QDecoration class provides a couple of static
|
||||
functions, startMove() and startResize(), which start a move or
|
||||
resize action by making the appropriate decoration region active
|
||||
and grabbing the mouse input.
|
||||
|
||||
\sa QDecorationFactory, QDecorationPlugin, {Qt for Embedded Linux
|
||||
Architecture}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDecoration::QDecoration()
|
||||
|
||||
Constructs a decoration object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDecoration::~QDecoration()
|
||||
|
||||
Destroys this decoration object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDecoration::DecorationRegion
|
||||
|
||||
This enum describes the various regions of the window decoration.
|
||||
|
||||
\value All The entire region used by the window decoration.
|
||||
|
||||
\value Top The top border used to vertically resize the window.
|
||||
\value Bottom The bottom border used to vertically resize the window.
|
||||
\value Left The left border used to horizontally resize the window.
|
||||
\value Right The right border used to horizontally resize the window.
|
||||
\value TopLeft The top-left corner of the window used to resize the
|
||||
window both horizontally and vertically.
|
||||
\value TopRight The top-right corner of the window used to resize the
|
||||
window both horizontally and vertically.
|
||||
\value BottomLeft The bottom-left corner of the window used to resize the
|
||||
window both horizontally and vertically.
|
||||
\value BottomRight The bottom-right corner of the window used to resize the
|
||||
window both horizontally and vertically.
|
||||
\value Borders All the regions used to describe the window's borders.
|
||||
|
||||
\value Title The region containing the window title, used
|
||||
to move the window by dragging with the mouse cursor.
|
||||
\value Close The region occupied by the close button. Clicking in this
|
||||
region closes the window.
|
||||
\value Minimize The region occupied by the minimize button. Clicking in
|
||||
this region minimizes the window.
|
||||
\value Maximize The region occupied by the maximize button. Clicking in
|
||||
this region maximizes the window.
|
||||
\value Normalize The region occupied by a button used to restore a window's
|
||||
normal size. Clicking in this region restores a maximized
|
||||
window to its previous size. The region used for this
|
||||
button is often also the Maximize region.
|
||||
\value Menu The region occupied by the window's menu button. Clicking
|
||||
in this region opens the window operations (system) menu.
|
||||
\value Help The region occupied by the window's help button. Clicking
|
||||
in this region causes the context-sensitive help function
|
||||
to be enabled.
|
||||
\value Resize The region used to resize the window.
|
||||
\value Move The region used to move the window.
|
||||
\value None No region.
|
||||
|
||||
\sa region(), regionAt(), DecorationState
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDecoration::DecorationState
|
||||
|
||||
This enum describes the various states of a decoration region.
|
||||
|
||||
\value Normal The region is active
|
||||
\value Disabled The region is inactive.
|
||||
\value Hover The cursor is hovering over the region.
|
||||
\value Pressed The region is pressed.
|
||||
|
||||
\sa paint(), DecorationRegion
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRegion QDecoration::region(const QWidget *widget, const QRect & rectangle, int decorationRegion)
|
||||
|
||||
Implement this function to return the region specified by \a
|
||||
decorationRegion for the given top level \a widget.
|
||||
|
||||
The \a rectangle parameter specifies the rectangle the decoration
|
||||
is wrapped around. The \a decorationRegion is a bitmask of the
|
||||
values described by the DecorationRegion enum.
|
||||
|
||||
\sa regionAt(), paint()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRegion QDecoration::region(const QWidget *widget, int decorationRegion)
|
||||
\overload
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDecoration::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
|
||||
DecorationState state)
|
||||
|
||||
Implement this function to paint the border and title decoration
|
||||
for the specified top level \a widget using the given \a painter
|
||||
and decoration \a state. The specified \a decorationRegion is a
|
||||
bitmask of the values described by the DecorationRegion enum.
|
||||
|
||||
Note that \l{Qt for Embedded Linux} expects this function to return true if
|
||||
any of the widget's decorations are repainted; otherwise it should
|
||||
return false.
|
||||
|
||||
\sa region()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDecoration::regionAt(const QWidget *widget, const QPoint &point)
|
||||
|
||||
Returns the type of the first region of the specified top level \a
|
||||
widget containing the given \a point.
|
||||
|
||||
The return value is one of the DecorationRegion enum's values. Use
|
||||
the region() function to retrieve the actual region. If none of
|
||||
the widget's regions contain the point, this function returns \l
|
||||
None.
|
||||
|
||||
\sa region()
|
||||
*/
|
||||
int QDecoration::regionAt(const QWidget *w, const QPoint &point)
|
||||
{
|
||||
int regions[] = {
|
||||
TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight, // Borders first
|
||||
Menu, Title, Help, Minimize, Normalize, Maximize, Close, // then buttons
|
||||
None
|
||||
};
|
||||
|
||||
// char *regions_str[] = {
|
||||
// "TopLeft", "Top", "TopRight", "Left", "Right", "BottomLeft", "Bottom", "BottomRight",
|
||||
// "Menu", "Title", "Help", "Minimize", "Normalize", "Maximize", "Close",
|
||||
// "None"
|
||||
// };
|
||||
|
||||
// First check to see if within all regions at all
|
||||
QRegion reg = region(w, w->geometry(), All);
|
||||
if (!reg.contains(point)) {
|
||||
return None;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (regions[i]) {
|
||||
reg = region(w, w->geometry(), regions[i]);
|
||||
if (reg.contains(point)) {
|
||||
// qDebug("In region %s", regions_str[i]);
|
||||
return regions[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_MENU
|
||||
/*!
|
||||
Builds the system menu for the given top level \a widget, adding
|
||||
\gui Restore, \gui Move, \gui Size, \gui Minimize, \gui Maximize
|
||||
and \gui Close actions to the given \a menu.
|
||||
|
||||
\sa menuTriggered()
|
||||
*/
|
||||
void QDecoration::buildSysMenu(QWidget *widget, QMenu *menu)
|
||||
{
|
||||
QDecorationAction *act = new QDecorationAction(QLatin1String("Restore"),
|
||||
menu, Maximize);
|
||||
act->setEnabled(widget->windowState() & Qt::WindowMaximized);
|
||||
menu->addAction(act);
|
||||
act = new QDecorationAction(QLatin1String("Move"), menu, Move);
|
||||
act->setEnabled(!(widget->windowState() & Qt::WindowMaximized));
|
||||
menu->addAction(act);
|
||||
menu->addAction(new QDecorationAction(QLatin1String("Size"), menu, Resize));
|
||||
act = new QDecorationAction(QLatin1String("Minimize"), menu, Minimize);
|
||||
menu->addAction(act);
|
||||
act = new QDecorationAction(QLatin1String("Maximize"), menu, Maximize);
|
||||
act->setDisabled(widget->windowState() & Qt::WindowMaximized);
|
||||
menu->addAction(act);
|
||||
menu->addSeparator();
|
||||
menu->addAction(new QDecorationAction(QLatin1String("Close"), menu, Close));
|
||||
}
|
||||
|
||||
/*!
|
||||
This function is called whenever an action in a top level widget's
|
||||
menu is triggered, and simply calls the regionClicked() function
|
||||
passing the \a widget and \a action parameters as arguments.
|
||||
|
||||
\sa buildSysMenu()
|
||||
*/
|
||||
void QDecoration::menuTriggered(QWidget *widget, QAction *action)
|
||||
{
|
||||
QDecorationAction *decAction = static_cast<QDecorationAction *>(action);
|
||||
regionClicked(widget, decAction->reg);
|
||||
}
|
||||
#endif // QT_NO_MENU
|
||||
|
||||
/*!
|
||||
\fn void QDecoration::regionClicked(QWidget *widget, int region)
|
||||
|
||||
Handles the event that the specified \a region in the given top
|
||||
level \a widget is activated by a single click (the \a region
|
||||
parameter is described using the DecorationRegion enum).
|
||||
|
||||
This function is called whenever a region in a top level widget is
|
||||
clicked; the default implementation responds to clicks on items in
|
||||
the system menu, performing the requested actions.
|
||||
|
||||
\sa regionDoubleClicked(), region()
|
||||
*/
|
||||
void QDecoration::regionClicked(QWidget *widget, int reg)
|
||||
{
|
||||
switch(reg) {
|
||||
case Move:
|
||||
startMove(widget);
|
||||
break;
|
||||
case Resize:
|
||||
startResize(widget);
|
||||
break;
|
||||
case Help:
|
||||
#ifndef QT_NO_WHATSTHIS
|
||||
if (QWhatsThis::inWhatsThisMode())
|
||||
QWhatsThis::leaveWhatsThisMode();
|
||||
else
|
||||
QWhatsThis::enterWhatsThisMode();
|
||||
#endif
|
||||
break;
|
||||
case Close:
|
||||
widget->close();
|
||||
break;
|
||||
case Normalize:
|
||||
widget->showNormal();
|
||||
break;
|
||||
case Maximize:
|
||||
if (widget->windowState() & Qt::WindowMaximized)
|
||||
widget->showNormal();
|
||||
else
|
||||
widget->showMaximized();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDecoration::regionDoubleClicked(QWidget *widget, int region)
|
||||
|
||||
Handles the event that the specified \a region in the given top
|
||||
level \a widget is activated by a double click (the region
|
||||
parameter is described using the DecorationRegion enum).
|
||||
|
||||
This function is called whenever a region in a top level widget is
|
||||
double clicked; the default implementation responds to a double
|
||||
click on the widget's title, toggling its size between the maximum
|
||||
and its normal size.
|
||||
|
||||
\sa regionClicked(), region()
|
||||
*/
|
||||
void QDecoration::regionDoubleClicked(QWidget *widget, int reg)
|
||||
{
|
||||
switch(reg)
|
||||
{
|
||||
case Title: {
|
||||
if (widget->windowState() & Qt::WindowMaximized)
|
||||
widget->showNormal();
|
||||
else
|
||||
widget->showMaximized();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Starts to move the given top level \a widget by making its \l
|
||||
Title region active and grabbing the mouse input.
|
||||
|
||||
\sa startResize()
|
||||
*/
|
||||
void QDecoration::startMove(QWidget *widget)
|
||||
{
|
||||
#ifdef QT_NO_QWS_MANAGER
|
||||
Q_UNUSED(widget);
|
||||
#else
|
||||
QWSManager *manager = widget->d_func()->topData()->qwsManager;
|
||||
if (manager)
|
||||
manager->startMove();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Starts to resize the given top level \a widget by making its \l
|
||||
BottomRight region active and grabbing the mouse input.
|
||||
|
||||
\sa startMove()
|
||||
*/
|
||||
void QDecoration::startResize(QWidget *widget)
|
||||
{
|
||||
#ifdef QT_NO_QWS_MANAGER
|
||||
Q_UNUSED(widget);
|
||||
#else
|
||||
QWSManager *manager = widget->d_func()->topData()->qwsManager;
|
||||
if (manager)
|
||||
manager->startResize();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,124 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATION_QWS_H
|
||||
#define QDECORATION_QWS_H
|
||||
|
||||
#include <QtGui/qregion.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
#include <QtGui/qaction.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QPopupMenu;
|
||||
class QMenu;
|
||||
|
||||
#ifndef QT_NO_ACTION
|
||||
class QDecorationAction : public QAction
|
||||
{
|
||||
public:
|
||||
QDecorationAction(const QString &text, QObject* parent, int region)
|
||||
: QAction(text, parent), reg(region) {}
|
||||
int reg;
|
||||
};
|
||||
#endif // QT_NO_ACTION
|
||||
|
||||
/*
|
||||
Implements decoration styles
|
||||
*/
|
||||
class Q_GUI_EXPORT QDecoration
|
||||
{
|
||||
public:
|
||||
QDecoration() {}
|
||||
virtual ~QDecoration() {}
|
||||
|
||||
/* AABBBBBBBBBBCC Items in DecorationRegion:
|
||||
AijjjjjjjklmnC
|
||||
A C A = TopLeft B = Top C = TopRight
|
||||
D E D = Left E = Right
|
||||
D E F = BottomLeft H = Bottom G = BottomRight
|
||||
F G i = Menu j = Title k = Help
|
||||
FFHHHHHHHHHHGG l = Minimize m = Maximize n = Close
|
||||
|
||||
*/
|
||||
|
||||
enum DecorationRegion {
|
||||
None = 0x0000000000, All = 0x7fffffff,
|
||||
TopLeft = 0x0000000001, Top = 0x0000000002, TopRight = 0x0000000004,
|
||||
Left = 0x0000000008, Right = 0x0000000010,
|
||||
BottomLeft = 0x0000000020, Bottom = 0x0000000040, BottomRight = 0x0000000080,
|
||||
Borders = 0x00000000ff,
|
||||
Menu = 0x0000000100, Title = 0x0000000200, Help = 0x0000000400,
|
||||
Minimize = 0x0000000800, Maximize = 0x0000001000, Normalize = 0x0000002000,
|
||||
Close = 0x0000004000, Move = 0x0000008000, Resize = 0x0000010000
|
||||
};
|
||||
|
||||
enum DecorationState { Normal = 0x04, Disabled = 0x08, Hover = 0x01, Pressed = 0x02 };
|
||||
|
||||
virtual QRegion region(const QWidget *w, const QRect &rect, int decorationRegion = All ) = 0;
|
||||
QRegion region(const QWidget *w, int decorationRegion = All )
|
||||
{ return region(w, w->rect(), decorationRegion); }
|
||||
virtual int regionAt(const QWidget *w, const QPoint &point);
|
||||
|
||||
virtual void regionClicked(QWidget *widget, int region);
|
||||
virtual void regionDoubleClicked(QWidget *widget, int region);
|
||||
#ifndef QT_NO_MENU
|
||||
virtual void buildSysMenu(QWidget *widget, QMenu *menu);
|
||||
void menuTriggered(QWidget *widget, QAction *action);
|
||||
#endif
|
||||
|
||||
static void startMove(QWidget *widget);
|
||||
static void startResize(QWidget *widget);
|
||||
|
||||
virtual bool paint(QPainter *p, const QWidget *w, int decorationRegion = All,
|
||||
DecorationState state = Normal) = 0;
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATION_QWS_H
|
@ -1,803 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qwidget.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpaintengine.h>
|
||||
#include <qdrawutil.h>
|
||||
#include "qdecorationdefault_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_DEFAULT) || defined(QT_PLUGIN)
|
||||
|
||||
QPixmap *QDecorationDefault::staticHelpPixmap = 0;
|
||||
QPixmap *QDecorationDefault::staticMenuPixmap = 0;
|
||||
QPixmap *QDecorationDefault::staticClosePixmap = 0;
|
||||
QPixmap *QDecorationDefault::staticMinimizePixmap = 0;
|
||||
QPixmap *QDecorationDefault::staticMaximizePixmap = 0;
|
||||
QPixmap *QDecorationDefault::staticNormalizePixmap = 0;
|
||||
|
||||
#ifndef QT_NO_IMAGEFORMAT_XPM
|
||||
|
||||
/* XPM */
|
||||
static const char * const default_menu_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"16 16 11 1",
|
||||
/* colors */
|
||||
" c #000000",
|
||||
". c #336600",
|
||||
"X c #666600",
|
||||
"o c #99CC00",
|
||||
"O c #999933",
|
||||
"+ c #333300",
|
||||
"@ c #669900",
|
||||
"# c #999900",
|
||||
"$ c #336633",
|
||||
"% c #666633",
|
||||
"& c #99CC33",
|
||||
/* pixels */
|
||||
"oooooooooooooooo",
|
||||
"oooooooooooooooo",
|
||||
"ooooo#.++X#ooooo",
|
||||
"ooooX Xoooo",
|
||||
"oooX XO#% X&oo",
|
||||
"oo# Ooo&@O Ooo",
|
||||
"oo. Xoo#+ @X Xoo",
|
||||
"oo+ OoO+ +O# +oo",
|
||||
"oo+ #O+ +## +oo",
|
||||
"oo. %@ ++ +. Xoo",
|
||||
"oo# O@OO+ #oo",
|
||||
"oooX X##$ Ooo",
|
||||
"ooooX Xoo",
|
||||
"oooo&OX++X#OXooo",
|
||||
"oooooooooooooooo",
|
||||
"oooooooooooooooo"
|
||||
};
|
||||
|
||||
static const char * const default_help_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ...... ",
|
||||
" ..XXXXXX ",
|
||||
" .XX .XX ",
|
||||
" .XX .XX ",
|
||||
" ..XX ",
|
||||
" ..XX ",
|
||||
" ..XX ",
|
||||
" .XX ",
|
||||
" .XX ",
|
||||
" .. ",
|
||||
" .XX ",
|
||||
" .XX ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const default_close_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" .X .X ",
|
||||
" .XX .XX ",
|
||||
" .XX .XX ",
|
||||
" .XX .XX ",
|
||||
" .XX.XX ",
|
||||
" .XXX ",
|
||||
" .XXX ",
|
||||
" .XX.XX ",
|
||||
" .XX .XX ",
|
||||
" .XX .XX ",
|
||||
" .XX .XX ",
|
||||
" .X .X ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const default_maximize_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ........... ",
|
||||
" .XXXXXXXXXX ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X........X ",
|
||||
" .XXXXXXXXXX ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const default_minimize_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ... ",
|
||||
" . X ",
|
||||
" .XX ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const default_normalize_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ........ ",
|
||||
" .XXXXXXXX ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" ....X... .X ",
|
||||
" .XXXXXXXX .X ",
|
||||
" .X .XXXX ",
|
||||
" .X .X ",
|
||||
" .X .X ",
|
||||
" .X......X ",
|
||||
" .XXXXXXXX ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
#endif // QT_NO_IMAGEFORMAT_XPM
|
||||
|
||||
/*!
|
||||
\class QDecorationDefault
|
||||
\since 4.4
|
||||
\ingroup qws
|
||||
\brief The QDecorationDefault class is a base class providing default window decorations.
|
||||
|
||||
See the documentation for class QDecoration for a detailed
|
||||
description. This subclass of QDecoration provides standard
|
||||
icons for the decoration regions.
|
||||
|
||||
Note that this class is non-portable and only available in
|
||||
\l{Qt for Embedded Linux}.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Default constructor.
|
||||
*/
|
||||
QDecorationDefault::QDecorationDefault()
|
||||
: QDecoration()
|
||||
{
|
||||
menu_width = 20;
|
||||
help_width = 20;
|
||||
close_width = 20;
|
||||
minimize_width = 20;
|
||||
maximize_width = 20;
|
||||
normalize_width = 20;
|
||||
}
|
||||
|
||||
/*!
|
||||
The constructor deletes the static pixmaps.
|
||||
*/
|
||||
QDecorationDefault::~QDecorationDefault()
|
||||
{
|
||||
delete staticMenuPixmap;
|
||||
delete staticClosePixmap;
|
||||
delete staticMinimizePixmap;
|
||||
delete staticMaximizePixmap;
|
||||
delete staticNormalizePixmap;
|
||||
|
||||
// This makes it safe to delete and then create a QDecorationDefault
|
||||
staticMenuPixmap = 0;
|
||||
staticClosePixmap = 0;
|
||||
staticMinimizePixmap = 0;
|
||||
staticMaximizePixmap = 0;
|
||||
staticNormalizePixmap = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const char **QDecorationDefault::xpmForRegion(int region)
|
||||
|
||||
Returns a pointer to the X pixmap for the icon specified by
|
||||
\a region. An X pixmap is an ASCII-text-based image. The value
|
||||
of \a region must be one of a subset of the values of enum
|
||||
DecorationRegion. The supported values are \e Help, \e Menu,
|
||||
\e Close, \e Minimize, \e Maximize, and \e Normalize. Other
|
||||
values of \a region cause zero to be returned.
|
||||
|
||||
\sa QDecoration::DecorationRegion
|
||||
*/
|
||||
const char **QDecorationDefault::xpmForRegion(int reg)
|
||||
{
|
||||
#ifdef QT_NO_IMAGEFORMAT_XPM
|
||||
Q_UNUSED(reg);
|
||||
#else
|
||||
switch(reg)
|
||||
{
|
||||
case Help:
|
||||
return (const char **)default_help_xpm;
|
||||
case Menu:
|
||||
return (const char **)default_menu_xpm;
|
||||
case Close:
|
||||
return (const char **)default_close_xpm;
|
||||
case Minimize:
|
||||
return (const char **)default_minimize_xpm;
|
||||
case Maximize:
|
||||
return (const char **)default_maximize_xpm;
|
||||
case Normalize:
|
||||
return (const char **)default_normalize_xpm;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QPixmap QDecorationDefault::pixmapFor(const QWidget *widget,
|
||||
int decorationRegion, int &xoff, int &yoff)
|
||||
|
||||
Returns a pointer to the QPixmap for the widget specified by \a widget and
|
||||
\a decorationRegion. The returned QPixmap is constructed from the default
|
||||
X pixmap obtained from xpmForRegion().
|
||||
|
||||
\a xoff and \a yoff specify the offset for the pixmap.
|
||||
|
||||
The value of \a decorationRegion must be one of a subset of the values
|
||||
of enum DecorationRegion. The supported values are \e Help,
|
||||
\e Menu, \e Close, \e Minimize, \e Maximize, and \e Normalize.
|
||||
Other values of \a decorationRegion return 0.
|
||||
|
||||
\sa QDecoration::DecorationRegion
|
||||
*/
|
||||
QPixmap QDecorationDefault::pixmapFor(const QWidget *widget,
|
||||
int decorationRegion,
|
||||
int &xoff,
|
||||
int &/*yoff*/)
|
||||
{
|
||||
#ifdef QT_NO_IMAGEFORMAT_XPM
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(decorationRegion);
|
||||
Q_UNUSED(xoff);
|
||||
return QPixmap();
|
||||
#else
|
||||
static const char **staticHelpPixmapXPM = 0;
|
||||
static const char **staticMenuPixmapXPM = 0;
|
||||
static const char **staticClosePixmapXPM = 0;
|
||||
static const char **staticMinimizePixmapXPM = 0;
|
||||
static const char **staticMaximizePixmapXPM = 0;
|
||||
static const char **staticNormalizePixmapXPM = 0;
|
||||
const char **xpm;
|
||||
|
||||
// Why don't we just use/extend the enum type...
|
||||
|
||||
if (staticHelpPixmapXPM != (xpm = xpmForRegion(Help)) || !staticHelpPixmap) {
|
||||
staticHelpPixmapXPM = xpm;
|
||||
staticHelpPixmap = new QPixmap(xpm);
|
||||
}
|
||||
if (staticMenuPixmapXPM != (xpm = xpmForRegion(Menu)) || !staticMenuPixmap) {
|
||||
staticMenuPixmapXPM = xpm;
|
||||
staticMenuPixmap = new QPixmap(xpm);
|
||||
}
|
||||
if (staticClosePixmapXPM != (xpm = xpmForRegion(Close)) || !staticClosePixmap) {
|
||||
staticClosePixmapXPM = xpm;
|
||||
staticClosePixmap = new QPixmap(xpm);
|
||||
}
|
||||
if (staticMinimizePixmapXPM != (xpm = xpmForRegion(Minimize)) || !staticMinimizePixmap) {
|
||||
staticMinimizePixmapXPM = xpm;
|
||||
staticMinimizePixmap = new QPixmap(xpm);
|
||||
}
|
||||
if (staticMaximizePixmapXPM != (xpm = xpmForRegion(Maximize)) || !staticMaximizePixmap) {
|
||||
staticMaximizePixmapXPM = xpm;
|
||||
staticMaximizePixmap = new QPixmap(xpm);
|
||||
}
|
||||
if (staticNormalizePixmapXPM != (xpm = xpmForRegion(Normalize)) || !staticNormalizePixmap) {
|
||||
staticNormalizePixmapXPM = xpm;
|
||||
staticNormalizePixmap = new QPixmap(xpm);
|
||||
}
|
||||
|
||||
const QPixmap *pm = 0;
|
||||
|
||||
switch (decorationRegion) {
|
||||
case Help:
|
||||
pm = staticHelpPixmap;
|
||||
break;
|
||||
case Menu:
|
||||
if (!widget->windowIcon().isNull())
|
||||
return widget->windowIcon().pixmap(16,16); //##### QIcon::pixmap() needs a size !!!!!!"
|
||||
if (!pm) {
|
||||
xoff = 1;
|
||||
pm = staticMenuPixmap;
|
||||
}
|
||||
break;
|
||||
case Close:
|
||||
pm = staticClosePixmap;
|
||||
break;
|
||||
case Maximize:
|
||||
pm = staticMaximizePixmap;
|
||||
break;
|
||||
case Normalize:
|
||||
pm = staticNormalizePixmap;
|
||||
break;
|
||||
case Minimize:
|
||||
pm = staticMinimizePixmap;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return *pm;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int QDecorationDefault::titleBarHeight(const QWidget *widget)
|
||||
|
||||
Returns the title bar height in pixels for the given \a widget. It is the
|
||||
greater of 20, or the sum of the application font's line spacing value
|
||||
plus a border width fudge factor.
|
||||
*/
|
||||
int QDecorationDefault::titleBarHeight(const QWidget *)
|
||||
{
|
||||
return qMax(20, QApplication::fontMetrics().height() + BORDER_WIDTH);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the region specified by \a decorationRegion for the
|
||||
top-level \a widget. \a rect specifies the rectangle the decoration
|
||||
wraps. The value of \a decorationRegion is a combination of the
|
||||
bitmask values of enum DecorationRegion.
|
||||
*/
|
||||
QRegion QDecorationDefault::region(const QWidget *widget,
|
||||
const QRect &rect,
|
||||
int decorationRegion)
|
||||
{
|
||||
Qt::WindowFlags flags = widget->windowFlags();
|
||||
bool hasBorder = !widget->isMaximized();
|
||||
bool hasTitle = flags & Qt::WindowTitleHint;
|
||||
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
|
||||
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
|
||||
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
|
||||
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
|
||||
int state = widget->windowState();
|
||||
bool isMinimized = state & Qt::WindowMinimized;
|
||||
bool isMaximized = state & Qt::WindowMaximized;
|
||||
|
||||
int titleHeight = hasTitle ? titleBarHeight(widget) : 0;
|
||||
int bw = hasBorder ? BORDER_WIDTH : 0;
|
||||
int bbw = hasBorder ? BOTTOM_BORDER_WIDTH : 0;
|
||||
|
||||
QRegion region;
|
||||
switch (decorationRegion) {
|
||||
case All: {
|
||||
QRect r(rect.left() - bw,
|
||||
rect.top() - titleHeight - bw,
|
||||
rect.width() + 2 * bw,
|
||||
rect.height() + titleHeight + bw + bbw);
|
||||
region = r;
|
||||
region -= rect;
|
||||
}
|
||||
break;
|
||||
|
||||
case Title: {
|
||||
QRect r(rect.left()
|
||||
+ (hasSysMenu ? menu_width : 0),
|
||||
rect.top() - titleHeight,
|
||||
rect.width()
|
||||
- (hasSysMenu ? menu_width : 0)
|
||||
- close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- (hasMinimize ? minimize_width : 0)
|
||||
- (hasContextHelp ? help_width : 0),
|
||||
|
||||
titleHeight);
|
||||
if (r.width() > 0)
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case Top: {
|
||||
QRect r(rect.left() + CORNER_GRAB,
|
||||
rect.top() - titleHeight - bw,
|
||||
rect.width() - 2 * CORNER_GRAB,
|
||||
bw);
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case Left: {
|
||||
QRect r(rect.left() - bw,
|
||||
rect.top() - titleHeight + CORNER_GRAB,
|
||||
bw,
|
||||
rect.height() + titleHeight - 2 * CORNER_GRAB);
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case Right: {
|
||||
QRect r(rect.right() + 1,
|
||||
rect.top() - titleHeight + CORNER_GRAB,
|
||||
bw,
|
||||
rect.height() + titleHeight - 2 * CORNER_GRAB);
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case Bottom: {
|
||||
QRect r(rect.left() + CORNER_GRAB,
|
||||
rect.bottom() + 1,
|
||||
rect.width() - 2 * CORNER_GRAB,
|
||||
bw);
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case TopLeft: {
|
||||
QRect r1(rect.left() - bw,
|
||||
rect.top() - bw - titleHeight,
|
||||
CORNER_GRAB + bw,
|
||||
bw);
|
||||
|
||||
QRect r2(rect.left() - bw,
|
||||
rect.top() - bw - titleHeight,
|
||||
bw,
|
||||
CORNER_GRAB + bw);
|
||||
|
||||
region = QRegion(r1) + r2;
|
||||
}
|
||||
break;
|
||||
|
||||
case TopRight: {
|
||||
QRect r1(rect.right() - CORNER_GRAB,
|
||||
rect.top() - bw - titleHeight,
|
||||
CORNER_GRAB + bw,
|
||||
bw);
|
||||
|
||||
QRect r2(rect.right() + 1,
|
||||
rect.top() - bw - titleHeight,
|
||||
bw,
|
||||
CORNER_GRAB + bw);
|
||||
|
||||
region = QRegion(r1) + r2;
|
||||
}
|
||||
break;
|
||||
|
||||
case BottomLeft: {
|
||||
QRect r1(rect.left() - bw,
|
||||
rect.bottom() + 1,
|
||||
CORNER_GRAB + bw,
|
||||
bw);
|
||||
|
||||
QRect r2(rect.left() - bw,
|
||||
rect.bottom() - CORNER_GRAB,
|
||||
bw,
|
||||
CORNER_GRAB + bw);
|
||||
region = QRegion(r1) + r2;
|
||||
}
|
||||
break;
|
||||
|
||||
case BottomRight: {
|
||||
QRect r1(rect.right() - CORNER_GRAB,
|
||||
rect.bottom() + 1,
|
||||
CORNER_GRAB + bw,
|
||||
bw);
|
||||
|
||||
QRect r2(rect.right() + 1,
|
||||
rect.bottom() - CORNER_GRAB,
|
||||
bw,
|
||||
CORNER_GRAB + bw);
|
||||
region = QRegion(r1) + r2;
|
||||
}
|
||||
break;
|
||||
|
||||
case Menu: {
|
||||
if (hasSysMenu) {
|
||||
region = QRect(rect.left(), rect.top() - titleHeight,
|
||||
menu_width, titleHeight);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Help: {
|
||||
if (hasContextHelp) {
|
||||
QRect r(rect.right()
|
||||
- close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- (hasMinimize ? minimize_width : 0)
|
||||
- help_width + 1, rect.top() - titleHeight,
|
||||
help_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Minimize: {
|
||||
if (hasMinimize && !isMinimized) {
|
||||
QRect r(rect.right() - close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- minimize_width + 1, rect.top() - titleHeight,
|
||||
minimize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Maximize: {
|
||||
if (hasMaximize && !isMaximized) {
|
||||
QRect r(rect.right() - close_width - maximize_width + 1,
|
||||
rect.top() - titleHeight, maximize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Normalize: {
|
||||
if (hasMinimize && isMinimized) {
|
||||
QRect r(rect.right() - close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- minimize_width + 1, rect.top() - titleHeight,
|
||||
minimize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
} else if (hasMaximize && isMaximized) {
|
||||
QRect r(rect.right() - close_width - maximize_width + 1,
|
||||
rect.top() - titleHeight, maximize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Close: {
|
||||
QRect r(rect.right() - close_width + 1, rect.top() - titleHeight,
|
||||
close_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
int i = 1;
|
||||
while (i) {
|
||||
if (i & decorationRegion)
|
||||
region += this->region(widget, rect, i);
|
||||
i <<= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
/*!
|
||||
Paints the border and title decoration for the top-level \a widget
|
||||
using the \a painter provided and the decoration \a state. The value
|
||||
of \a decorationRegion is a combination of the bitmask values of
|
||||
enum DecorationRegion.
|
||||
|
||||
Note that Qt for Embedded Linux expects this function to return true if any of
|
||||
the widget's decorations are repainted; otherwise it returns false.
|
||||
*/
|
||||
bool QDecorationDefault::paint(QPainter *painter,
|
||||
const QWidget *widget,
|
||||
int decorationRegion,
|
||||
DecorationState state)
|
||||
{
|
||||
if (decorationRegion == None)
|
||||
return false;
|
||||
|
||||
const QRect titleRect = QDecoration::region(widget, Title).boundingRect();
|
||||
const QPalette pal = QApplication::palette();
|
||||
int titleHeight = titleRect.height();
|
||||
int titleWidth = titleRect.width();
|
||||
QRegion oldClipRegion = painter->clipRegion();
|
||||
|
||||
|
||||
Qt::WindowFlags flags = widget->windowFlags();
|
||||
bool hasBorder = !widget->isMaximized();
|
||||
bool hasTitle = flags & Qt::WindowTitleHint;
|
||||
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
|
||||
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
|
||||
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
|
||||
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
|
||||
|
||||
bool paintAll = (decorationRegion == int(All));
|
||||
bool handled = false;
|
||||
|
||||
bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
|
||||
|
||||
if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
|
||||
if (hasTitle) { // reduce flicker
|
||||
QRect rect(widget->rect());
|
||||
QRect r(rect.left(), rect.top() - titleHeight,
|
||||
rect.width(), titleHeight);
|
||||
painter->setClipRegion(oldClipRegion - r);
|
||||
}
|
||||
QRect br = QDecoration::region(widget).boundingRect();
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
qDrawWinPanel(painter, br.x(), br.y(), br.width(),
|
||||
br.height(), pal, false,
|
||||
&pal.brush(QPalette::Window));
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if ((paintAll || decorationRegion & Title && titleWidth > 0) && state == Normal && hasTitle) {
|
||||
painter->setClipRegion(oldClipRegion);
|
||||
QBrush titleBrush;
|
||||
QPen titlePen;
|
||||
|
||||
if (widget == qApp->activeWindow()) {
|
||||
titleBrush = pal.brush(QPalette::Highlight);
|
||||
titlePen = pal.color(QPalette::HighlightedText);
|
||||
} else {
|
||||
titleBrush = pal.brush(QPalette::Window);
|
||||
titlePen = pal.color(QPalette::Text);
|
||||
}
|
||||
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
qDrawShadePanel(painter,
|
||||
titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(),
|
||||
pal, true, 1, &titleBrush);
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
|
||||
painter->setPen(titlePen);
|
||||
painter->drawText(titleRect.x() + 4, titleRect.y(),
|
||||
titleRect.width() - 8, titleRect.height(),
|
||||
Qt::AlignVCenter, windowTitleFor(widget));
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if (state != Hover) {
|
||||
painter->setClipRegion(oldClipRegion);
|
||||
if ((paintAll || decorationRegion & Menu) && hasSysMenu) {
|
||||
paintButton(painter, widget, Menu, state, pal);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if ((paintAll || decorationRegion & Help) && hasContextHelp) {
|
||||
paintButton(painter, widget, Help, state, pal);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if ((paintAll || decorationRegion & Minimize) && hasMinimize) {
|
||||
paintButton(painter, widget, Minimize, state, pal);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if ((paintAll || decorationRegion & Maximize) && hasMaximize) {
|
||||
paintButton(painter, widget,
|
||||
((widget->windowState() & Qt::WindowMaximized)? Normalize : Maximize),
|
||||
state, pal);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
if (paintAll || decorationRegion & Close) {
|
||||
paintButton(painter, widget, Close, state, pal);
|
||||
handled |= true;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDecorationDefault::paintButton(QPainter *painter, const
|
||||
QWidget *widget, int buttonRegion, DecorationState state,
|
||||
const QPalette &palette)
|
||||
|
||||
Paints a region of the top-level \a widget. The region is
|
||||
painted in the specified decoration \a state using the
|
||||
\a painter and \a palette provided. The region to be painted is specified
|
||||
by \a buttonRegion, which is a combination of the bitmask values of
|
||||
DecorationRegion. If the value of \a buttonRegion is one of \e Help,
|
||||
\e Menu, \e Close, \e Minimize, \e Maximize, and \e Normalize, the
|
||||
button pixmap for that region is painted.
|
||||
|
||||
\sa pixmapFor()
|
||||
*/
|
||||
void QDecorationDefault::paintButton(QPainter *painter,
|
||||
const QWidget *widget,
|
||||
int buttonRegion,
|
||||
DecorationState state,
|
||||
const QPalette &pal)
|
||||
{
|
||||
int xoff = 2;
|
||||
int yoff = 2;
|
||||
|
||||
const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff);
|
||||
QRect brect(QDecoration::region(widget, buttonRegion).boundingRect());
|
||||
bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
|
||||
|
||||
if (state & QDecoration::Pressed) {
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
qDrawWinPanel(painter, brect, pal, true, &pal.brush(QPalette::Window));
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
++xoff;
|
||||
++yoff;
|
||||
} else {
|
||||
painter->fillRect(brect, pal.brush(QPalette::Window));
|
||||
}
|
||||
|
||||
if (!pm.isNull())
|
||||
painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm);
|
||||
}
|
||||
|
||||
extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*);
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString QDecorationDefault::windowTitleFor(const QWidget *widget) const
|
||||
{
|
||||
return qt_setWindowTitle_helperHelper(widget->windowTitle(), widget);
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_DECORATION_DEFAULT
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,101 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATIONDEFAULT_QWS_H
|
||||
#define QDECORATIONDEFAULT_QWS_H
|
||||
|
||||
#include <QtGui/qdecoration_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_DEFAULT) || defined(QT_PLUGIN)
|
||||
|
||||
#define CORNER_GRAB 16
|
||||
#define BORDER_WIDTH 4
|
||||
#define BOTTOM_BORDER_WIDTH BORDER_WIDTH
|
||||
|
||||
class Q_GUI_EXPORT QDecorationDefault : public QDecoration
|
||||
{
|
||||
public:
|
||||
QDecorationDefault();
|
||||
virtual ~QDecorationDefault();
|
||||
|
||||
virtual QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
|
||||
virtual bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
|
||||
DecorationState state = Normal);
|
||||
|
||||
protected:
|
||||
virtual int titleBarHeight(const QWidget *widget);
|
||||
|
||||
virtual void paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
|
||||
DecorationState state, const QPalette &pal);
|
||||
virtual QPixmap pixmapFor(const QWidget *widget, int decorationRegion, int &xoff, int &yoff);
|
||||
virtual const char **xpmForRegion(int region);
|
||||
|
||||
QString windowTitleFor(const QWidget *widget) const;
|
||||
|
||||
int menu_width;
|
||||
int help_width;
|
||||
int close_width;
|
||||
int minimize_width;
|
||||
int maximize_width;
|
||||
int normalize_width;
|
||||
|
||||
private:
|
||||
static QPixmap *staticHelpPixmap;
|
||||
static QPixmap *staticMenuPixmap;
|
||||
static QPixmap *staticClosePixmap;
|
||||
static QPixmap *staticMinimizePixmap;
|
||||
static QPixmap *staticMaximizePixmap;
|
||||
static QPixmap *staticNormalizePixmap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QT_NO_QWS_DECORATION_DEFAULT
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATIONDEFAULT_QWS_H
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdecorationfactory_qws.h"
|
||||
#include "qdecorationplugin_qws.h"
|
||||
#include "private/qfactoryloader_p.h"
|
||||
#include "qmutex.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qdecorationdefault_qws.h"
|
||||
#include "qdecorationwindows_qws.h"
|
||||
#include "qdecorationstyled_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QDecorationFactoryInterface_iid,
|
||||
QLatin1String("/decorations"), Qt::CaseInsensitive))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\class QDecorationFactory
|
||||
\ingroup qws
|
||||
\ingroup appearance
|
||||
|
||||
\brief The QDecorationFactory class creates window decorations in
|
||||
Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QDecorationFactory is used to detect and instantiate the available
|
||||
decorations, allowing \l{Qt for Embedded Linux} to load the preferred
|
||||
decoration into the application at runtime. The create() function
|
||||
returns a QDecoration object representing the decoration
|
||||
identified by a given key. The valid keys (i.e. the supported
|
||||
decorations) can be retrieved using the keys() function.
|
||||
|
||||
\l{Qt for Embedded Linux} provides three built-in decorations: \c Default,
|
||||
\c Styled and \c Windows. In addition, custom decorations can be
|
||||
added using Qt's \l {How to Create Qt Plugins}{plugin mechanism},
|
||||
i.e. by subclassing the QDecoration class and creating a mouse
|
||||
driver plugin (QDecorationPlugin).
|
||||
|
||||
\sa QDecoration, QDecorationPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Creates the decoration specified by the given \a key. Note that
|
||||
the keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
|
||||
QDecoration *QDecorationFactory::create(const QString& key)
|
||||
{
|
||||
QDecoration *ret = 0;
|
||||
QString decoration = key.toLower();
|
||||
#ifndef QT_NO_QWS_DECORATION_DEFAULT
|
||||
if (decoration == QLatin1String("default"))
|
||||
ret = new QDecorationDefault;
|
||||
else
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_DECORATION_WINDOWS
|
||||
if (decoration == QLatin1String("windows"))
|
||||
ret = new QDecorationWindows;
|
||||
else
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_DECORATION_STYLED
|
||||
if (decoration == QLatin1String("styled"))
|
||||
ret = new QDecorationStyled;
|
||||
else
|
||||
#endif
|
||||
{ } // Keep these here - they make the #ifdefery above work
|
||||
#ifndef QT_NO_LIBRARY
|
||||
if (!ret) {
|
||||
if (QDecorationFactoryInterface *factory = qobject_cast<QDecorationFactoryInterface*>(loader()->instance(decoration))) {
|
||||
ret = factory->create(decoration);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of valid keys, i.e., the available decorations.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
QStringList QDecorationFactory::keys()
|
||||
{
|
||||
QStringList list;
|
||||
#ifndef QT_NO_QWS_DECORATION_STYLED
|
||||
list << QLatin1String("Styled");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_DECORATION_DEFAULT
|
||||
list << QLatin1String("Default");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_DECORATION_WINDOWS
|
||||
list << QLatin1String("Windows");
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
QStringList plugins = loader()->keys();
|
||||
for (int i = 0; i < plugins.size(); ++i) {
|
||||
if (!list.contains(plugins.at(i)))
|
||||
list += plugins.at(i);
|
||||
}
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,66 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATIONFACTORY_QWS_H
|
||||
#define QDECORATIONFACTORY_QWS_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QDecoration;
|
||||
|
||||
class Q_GUI_EXPORT QDecorationFactory
|
||||
{
|
||||
public:
|
||||
static QStringList keys();
|
||||
static QDecoration *create(const QString&);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATIONFACTORY_QWS_H
|
@ -1,116 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdecorationplugin_qws.h"
|
||||
#include "qdecoration_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDecorationPlugin
|
||||
\ingroup qws
|
||||
\ingroup plugins
|
||||
|
||||
\brief The QDecorationPlugin class is an abstract base class for
|
||||
window decoration plugins in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides three ready-made decoration styles: \c
|
||||
Default, \c Styled and \c Windows. Custom decorations can be
|
||||
implemented by subclassing the QDecoration class and creating a
|
||||
decoration plugin.
|
||||
|
||||
A decoration plugin can be created by subclassing
|
||||
QDecorationPlugin and implementing the pure virtual keys() and
|
||||
create() functions. By exporting the derived class using the
|
||||
Q_EXPORT_PLUGIN2() macro, the default implementation of the
|
||||
QDecorationFactory class will automatically detect the plugin and
|
||||
load the driver into the application at run-time. See \l{How to
|
||||
Create Qt Plugins} for details.
|
||||
|
||||
To actually apply a decoration, use the
|
||||
QApplication::qwsSetDecoration() function.
|
||||
|
||||
\sa QDecoration, QDecorationFactory
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QDecorationPlugin::keys() const
|
||||
|
||||
Returns the list of valid keys, i.e., the decorations supported by
|
||||
this plugin.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDecoration *QDecorationPlugin::create(const QString &key)
|
||||
|
||||
Creates a decoration matching the given \a key. Note that keys are
|
||||
case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a decoration plugin with the given \a parent.
|
||||
|
||||
Note that this constructor is invoked automatically by the
|
||||
Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
|
||||
explicitly.
|
||||
*/
|
||||
QDecorationPlugin::QDecorationPlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the decoration plugin.
|
||||
|
||||
Note that Qt destroys a plugin automatically when it is no longer
|
||||
used, so there is no need for calling the destructor explicitly.
|
||||
*/
|
||||
QDecorationPlugin::~QDecorationPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATIONPLUGIN_QWS_H
|
||||
#define QDECORATIONPLUGIN_QWS_H
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QDecoration;
|
||||
|
||||
struct Q_GUI_EXPORT QDecorationFactoryInterface : public QFactoryInterface
|
||||
{
|
||||
virtual QDecoration *create(const QString &key) = 0;
|
||||
};
|
||||
|
||||
#define QDecorationFactoryInterface_iid "com.trolltech.Qt.QDecorationFactoryInterface"
|
||||
Q_DECLARE_INTERFACE(QDecorationFactoryInterface, QDecorationFactoryInterface_iid)
|
||||
|
||||
class Q_GUI_EXPORT QDecorationPlugin : public QObject, public QDecorationFactoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDecorationFactoryInterface:QFactoryInterface)
|
||||
public:
|
||||
explicit QDecorationPlugin(QObject *parent = 0);
|
||||
~QDecorationPlugin();
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QDecoration *create(const QString &key) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATIONPLUGIN_QWS_H
|
@ -1,313 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qwidget.h>
|
||||
#include <qpainter.h>
|
||||
#include <qdrawutil.h>
|
||||
#include "qdecorationstyled_qws.h"
|
||||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qpaintengine.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_STYLED) || defined(QT_PLUGIN)
|
||||
|
||||
QDecorationStyled::QDecorationStyled()
|
||||
: QDecorationDefault()
|
||||
{
|
||||
}
|
||||
|
||||
QDecorationStyled::~QDecorationStyled()
|
||||
{
|
||||
}
|
||||
|
||||
int QDecorationStyled::titleBarHeight(const QWidget *widget)
|
||||
{
|
||||
QStyleOptionTitleBar opt;
|
||||
opt.subControls = QStyle::SC_TitleBarLabel
|
||||
| QStyle::SC_TitleBarSysMenu
|
||||
| QStyle::SC_TitleBarNormalButton
|
||||
| QStyle::SC_TitleBarContextHelpButton
|
||||
| QStyle::SC_TitleBarMinButton
|
||||
| QStyle::SC_TitleBarMaxButton
|
||||
| QStyle::SC_TitleBarCloseButton;
|
||||
opt.titleBarFlags = widget->windowFlags();
|
||||
opt.direction = QApplication::layoutDirection();
|
||||
opt.text = windowTitleFor(widget);
|
||||
opt.icon = widget->windowIcon();
|
||||
opt.rect = widget->rect();
|
||||
|
||||
QStyle *style = QApplication::style();
|
||||
if (!style)
|
||||
return 18;
|
||||
|
||||
return style->pixelMetric(QStyle::PM_TitleBarHeight, &opt, 0);
|
||||
}
|
||||
|
||||
bool QDecorationStyled::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
|
||||
DecorationState state)
|
||||
{
|
||||
if (decorationRegion == None)
|
||||
return false;
|
||||
|
||||
bool isActive = (widget == qApp->activeWindow());
|
||||
QPalette pal = qApp->palette();
|
||||
//ideally, the difference between Active and Inactive should be enough, so we shouldn't need to test this
|
||||
if (!isActive) {
|
||||
//pal.setCurrentColorGroup(QPalette::Disabled); //Can't do this either, because of palette limitations
|
||||
//copied from Q3TitleBar:
|
||||
pal.setColor(QPalette::Inactive, QPalette::Highlight,
|
||||
pal.color(QPalette::Inactive, QPalette::Dark));
|
||||
pal.setColor(QPalette::Inactive, QPalette::Base,
|
||||
pal.color(QPalette::Inactive, QPalette::Dark));
|
||||
pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
|
||||
pal.color(QPalette::Inactive, QPalette::Window));
|
||||
}
|
||||
|
||||
Qt::WindowFlags flags = widget->windowFlags();
|
||||
bool hasBorder = !widget->isMaximized();
|
||||
bool hasTitle = flags & Qt::WindowTitleHint;
|
||||
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
|
||||
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
|
||||
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
|
||||
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
|
||||
|
||||
bool paintAll = (DecorationRegion(decorationRegion) == All);
|
||||
bool handled = false;
|
||||
|
||||
QStyle *style = QApplication::style();
|
||||
|
||||
// In the case of a borderless title bar, the title bar must be expanded one
|
||||
// borderWidth to the left, right and up.
|
||||
bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
|
||||
int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
|
||||
int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
|
||||
int titleExtra = noTitleBorder ? borderWidth : 0;
|
||||
|
||||
if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
|
||||
QRegion newClip = painter->clipRegion();
|
||||
if (hasTitle) { // reduce flicker
|
||||
QRect rect(widget->rect());
|
||||
QRect r(rect.left() - titleExtra, rect.top() - titleHeight,
|
||||
rect.width() + 2 * titleExtra, titleHeight);
|
||||
newClip -= r;
|
||||
}
|
||||
if (!newClip.isEmpty()) {
|
||||
QRect br = QDecoration::region(widget).boundingRect();
|
||||
painter->save();
|
||||
painter->setClipRegion(newClip);
|
||||
|
||||
QStyleOptionFrame opt;
|
||||
opt.palette = pal;
|
||||
opt.rect = br;
|
||||
opt.lineWidth = borderWidth;
|
||||
|
||||
if (isActive)
|
||||
opt.state |= QStyle::State_Active;
|
||||
bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
painter->fillRect(br, pal.window());
|
||||
if (porterDuff)
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
style->drawPrimitive(QStyle::PE_FrameWindow, &opt, painter, 0);
|
||||
painter->restore();
|
||||
|
||||
decorationRegion &= (~Borders);
|
||||
handled |= true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasTitle) {
|
||||
painter->save();
|
||||
|
||||
QStyleOptionTitleBar opt;
|
||||
opt.subControls = (decorationRegion & Title
|
||||
? QStyle::SC_TitleBarLabel : QStyle::SubControl(0))
|
||||
| (decorationRegion & Menu
|
||||
? QStyle::SC_TitleBarSysMenu : QStyle::SubControl(0))
|
||||
| (decorationRegion & Help
|
||||
? QStyle::SC_TitleBarContextHelpButton : QStyle::SubControl(0))
|
||||
| (decorationRegion & Minimize
|
||||
? QStyle::SC_TitleBarMinButton : QStyle::SubControl(0))
|
||||
| (decorationRegion & Maximize
|
||||
? QStyle::SC_TitleBarMaxButton : QStyle::SubControl(0))
|
||||
| (decorationRegion & (Minimize | Maximize)
|
||||
? QStyle::SC_TitleBarNormalButton : QStyle::SubControl(0))
|
||||
| (decorationRegion & Close
|
||||
? QStyle::SC_TitleBarCloseButton : QStyle::SubControl(0));
|
||||
opt.titleBarFlags = widget->windowFlags();
|
||||
opt.titleBarState = widget->windowState();
|
||||
if (isActive)
|
||||
opt.titleBarState |= QStyle::State_Active;
|
||||
opt.text = windowTitleFor(widget);
|
||||
opt.icon = widget->windowIcon();
|
||||
opt.palette = pal;
|
||||
opt.rect = QRect(widget->rect().x() - titleExtra, -titleHeight,
|
||||
widget->rect().width() + 2 * titleExtra, titleHeight);
|
||||
|
||||
if (paintAll) {
|
||||
painter->setClipRegion(opt.rect);
|
||||
} else {
|
||||
const QRect widgetRect = widget->rect();
|
||||
QRegion newClip = opt.rect;
|
||||
if (!(decorationRegion & Menu) && hasSysMenu)
|
||||
newClip -= region(widget, widgetRect, Menu);
|
||||
if (!(decorationRegion & Title) && hasTitle)
|
||||
newClip -= region(widget, widgetRect, Title);
|
||||
if (!(decorationRegion & Help) && hasContextHelp)
|
||||
newClip -= region(widget, widgetRect, Help);
|
||||
if (!(decorationRegion & Minimize) && hasMinimize)
|
||||
newClip -= region(widget, widgetRect, Minimize);
|
||||
if (!(decorationRegion & Maximize) && hasMaximize)
|
||||
newClip -= region(widget, widgetRect, Maximize);
|
||||
if (!(decorationRegion & (Minimize | Maximize)) && (hasMaximize | hasMinimize))
|
||||
newClip -= region(widget, widgetRect, Normal);
|
||||
if (!(decorationRegion & Close))
|
||||
newClip -= region(widget, widgetRect, Close);
|
||||
painter->setClipRegion(newClip);
|
||||
}
|
||||
|
||||
if (state == Pressed)
|
||||
opt.activeSubControls = opt.subControls;
|
||||
|
||||
style->drawComplexControl(QStyle::CC_TitleBar, &opt, painter, 0);
|
||||
painter->restore();
|
||||
|
||||
decorationRegion &= ~(Title | Menu | Help | Normalize | Minimize | Maximize | Close);
|
||||
handled |= true;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
QRegion QDecorationStyled::region(const QWidget *widget, const QRect &rect, int decorationRegion)
|
||||
{
|
||||
QStyle *style = QApplication::style();
|
||||
|
||||
// In the case of a borderless title bar, the title bar must be expanded one
|
||||
// borderWidth to the left, right and up.
|
||||
bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
|
||||
int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
|
||||
int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
|
||||
int titleExtra = noTitleBorder ? borderWidth : 0;
|
||||
|
||||
QRect inside = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
|
||||
rect.width() + 2 * titleExtra, titleHeight);
|
||||
|
||||
Qt::WindowFlags flags = widget->windowFlags();
|
||||
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
|
||||
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
|
||||
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
|
||||
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
|
||||
|
||||
QStyleOptionTitleBar opt;
|
||||
opt.subControls = QStyle::SC_TitleBarLabel
|
||||
| QStyle::SC_TitleBarSysMenu
|
||||
| QStyle::SC_TitleBarNormalButton
|
||||
| QStyle::SC_TitleBarMinButton
|
||||
| QStyle::SC_TitleBarMaxButton
|
||||
| QStyle::SC_TitleBarCloseButton;
|
||||
opt.titleBarFlags = widget->windowFlags();
|
||||
opt.direction = QApplication::layoutDirection();
|
||||
opt.text = windowTitleFor(widget);
|
||||
opt.icon = widget->windowIcon();
|
||||
opt.rect = inside;
|
||||
|
||||
QRegion region;
|
||||
switch (decorationRegion) {
|
||||
case Title:
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarLabel, 0);
|
||||
break;
|
||||
case Menu:
|
||||
if (hasSysMenu)
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarSysMenu, 0);
|
||||
break;
|
||||
case Help:
|
||||
if (hasContextHelp)
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarContextHelpButton,
|
||||
0);
|
||||
break;
|
||||
case Normalize:
|
||||
if (hasMaximize | hasMinimize)
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarNormalButton,
|
||||
0);
|
||||
break;
|
||||
case Minimize:
|
||||
if (hasMinimize)
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarMinButton,
|
||||
0);
|
||||
break;
|
||||
case Maximize:
|
||||
if (hasMaximize)
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarMaxButton,
|
||||
0);
|
||||
break;
|
||||
case Close:
|
||||
region = style->subControlRect(QStyle::CC_TitleBar, &opt,
|
||||
QStyle::SC_TitleBarCloseButton, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
region = QDecorationDefault::region(widget, rect, decorationRegion);
|
||||
}
|
||||
|
||||
opt.rect = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
|
||||
rect.width() + 2 * titleExtra,
|
||||
rect.height() + titleHeight + titleExtra);
|
||||
|
||||
QStyleHintReturnMask mask;
|
||||
style->styleHint(QStyle::SH_WindowFrame_Mask, &opt, 0, &mask);
|
||||
|
||||
return (mask.region.isEmpty() ? region : (region & mask.region));
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_DECORATION_STYLED
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,73 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATIONSTYLED_QWS_H
|
||||
#define QDECORATIONSTYLED_QWS_H
|
||||
|
||||
#include <QtGui/qdecorationdefault_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_STYLED) || defined(QT_PLUGIN)
|
||||
|
||||
class Q_GUI_EXPORT QDecorationStyled : public QDecorationDefault
|
||||
{
|
||||
public:
|
||||
QDecorationStyled();
|
||||
virtual ~QDecorationStyled();
|
||||
|
||||
QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
|
||||
bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
|
||||
DecorationState state = Normal);
|
||||
int titleBarHeight(const QWidget *widget);
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_DECORATION_STYLED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATIONSTYLED_QWS_H
|
@ -1,407 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qwidget.h>
|
||||
#include <qpainter.h>
|
||||
#include <qdrawutil.h>
|
||||
#include "qdecorationwindows_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_WINDOWS) || defined(QT_PLUGIN)
|
||||
|
||||
#ifndef QT_NO_IMAGEFORMAT_XPM
|
||||
|
||||
/* XPM */
|
||||
static const char * const win_close_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"X c #FFFFFF",
|
||||
"Y c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" Y. .Y ",
|
||||
" .. .. ",
|
||||
" .. .. ",
|
||||
" .YY. ",
|
||||
" Y..Y ",
|
||||
" .YY. ",
|
||||
" .. .. ",
|
||||
" .. .. ",
|
||||
" Y. .Y ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const win_help_xpm[] = {
|
||||
"16 16 3 1",
|
||||
" s None c None",
|
||||
". c #ffffff",
|
||||
"X c #000000",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" XXXXXX ",
|
||||
" XX XX ",
|
||||
" XX XX ",
|
||||
" XX ",
|
||||
" XX ",
|
||||
" XX ",
|
||||
" XX ",
|
||||
" ",
|
||||
" XX ",
|
||||
" XX ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const win_maximize_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"X c #FFFFFF",
|
||||
"Y c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" .......... ",
|
||||
" .......... ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" .......... ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const win_minimize_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"X c #FFFFFF",
|
||||
"Y c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ........ ",
|
||||
" ........ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
static const char * const win_normalize_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"X c #FFFFFF",
|
||||
"Y c #707070",
|
||||
" ",
|
||||
" ",
|
||||
" ......... ",
|
||||
" ......... ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" ......... . ",
|
||||
" ......... . ",
|
||||
" . . . ",
|
||||
" . .... ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" ......... ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
#endif // QT_NO_IMAGEFORMAT_XPM
|
||||
|
||||
|
||||
QDecorationWindows::QDecorationWindows()
|
||||
: QDecorationDefault()
|
||||
{
|
||||
menu_width = 16;
|
||||
help_width = 18;
|
||||
minimize_width = 18;
|
||||
maximize_width = 18;
|
||||
close_width = 18;
|
||||
}
|
||||
|
||||
QDecorationWindows::~QDecorationWindows()
|
||||
{
|
||||
}
|
||||
|
||||
const char **QDecorationWindows::xpmForRegion(int reg)
|
||||
{
|
||||
#ifdef QT_NO_IMAGEFORMAT_XPM
|
||||
Q_UNUSED(reg);
|
||||
#else
|
||||
switch(reg)
|
||||
{
|
||||
case Close:
|
||||
return (const char **)win_close_xpm;
|
||||
case Help:
|
||||
return (const char **)win_help_xpm;
|
||||
case Minimize:
|
||||
return (const char **)win_minimize_xpm;
|
||||
case Maximize:
|
||||
return (const char **)win_maximize_xpm;
|
||||
case Normalize:
|
||||
return (const char **)win_normalize_xpm;
|
||||
default:
|
||||
return QDecorationDefault::xpmForRegion(reg);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
QRegion QDecorationWindows::region(const QWidget *widget, const QRect &rect, int type)
|
||||
{
|
||||
Qt::WindowFlags flags = widget->windowFlags();
|
||||
bool hasTitle = flags & Qt::WindowTitleHint;
|
||||
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
|
||||
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
|
||||
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
|
||||
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
|
||||
const QFontMetrics fontMetrics = QApplication::fontMetrics();
|
||||
int titleHeight = hasTitle ? qMax(20, fontMetrics.height()) : 0;
|
||||
int state = widget->windowState();
|
||||
bool isMinimized = state & Qt::WindowMinimized;
|
||||
bool isMaximized = state & Qt::WindowMaximized;
|
||||
|
||||
QRegion region;
|
||||
switch (type) {
|
||||
case Menu: {
|
||||
if (hasSysMenu) {
|
||||
region = QRect(rect.left() + 2, rect.top() - titleHeight,
|
||||
menu_width, titleHeight);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Title: {
|
||||
QRect r(rect.left()
|
||||
+ (hasSysMenu ? menu_width + 4: 0),
|
||||
rect.top() - titleHeight,
|
||||
rect.width()
|
||||
- (hasSysMenu ? menu_width : 0)
|
||||
- close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- (hasMinimize ? minimize_width : 0)
|
||||
- (hasContextHelp ? help_width : 0)
|
||||
- 3,
|
||||
titleHeight);
|
||||
if (r.width() > 0)
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
case Help: {
|
||||
if (hasContextHelp) {
|
||||
QRect r(rect.right()
|
||||
- close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- (hasMinimize ? minimize_width : 0)
|
||||
- help_width - 3, rect.top() - titleHeight,
|
||||
help_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Minimize: {
|
||||
if (hasMinimize && !isMinimized) {
|
||||
QRect r(rect.right() - close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- minimize_width - 3, rect.top() - titleHeight,
|
||||
minimize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Maximize: {
|
||||
if (hasMaximize && !isMaximized) {
|
||||
QRect r(rect.right() - close_width - maximize_width - 3,
|
||||
rect.top() - titleHeight, maximize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Normalize: {
|
||||
if (hasMinimize && isMinimized) {
|
||||
QRect r(rect.right() - close_width
|
||||
- (hasMaximize ? maximize_width : 0)
|
||||
- minimize_width - 3, rect.top() - titleHeight,
|
||||
minimize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
} else if (hasMaximize && isMaximized) {
|
||||
QRect r(rect.right() - close_width - maximize_width - 3,
|
||||
rect.top() - titleHeight, maximize_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Close: {
|
||||
QRect r(rect.right() - close_width - 1, rect.top() - titleHeight,
|
||||
close_width, titleHeight);
|
||||
if (r.left() > rect.left() + titleHeight)
|
||||
region = r;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
region = QDecorationDefault::region(widget, rect, type);
|
||||
break;
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
bool QDecorationWindows::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
|
||||
DecorationState state)
|
||||
{
|
||||
if (decorationRegion == None)
|
||||
return false;
|
||||
|
||||
const QRect titleRect = QDecoration::region(widget, Title).boundingRect();
|
||||
const QPalette pal = QApplication::palette();
|
||||
QRegion oldClipRegion = painter->clipRegion();
|
||||
|
||||
bool paintAll = (decorationRegion == int(All));
|
||||
if ((paintAll || decorationRegion & Title && titleRect.width() > 0) && state == Normal
|
||||
&& (widget->windowFlags() & Qt::WindowTitleHint) ) {
|
||||
painter->setClipRegion(oldClipRegion);
|
||||
QColor fromBrush, toBrush;
|
||||
QPen titlePen;
|
||||
|
||||
if (widget == qApp->activeWindow() || qApp->activeWindow() == qApp->activePopupWidget()) {
|
||||
fromBrush = pal.color(QPalette::Highlight);
|
||||
titlePen = pal.color(QPalette::HighlightedText);
|
||||
} else {
|
||||
fromBrush = pal.color(QPalette::Window);
|
||||
titlePen = pal.color(QPalette::Text);
|
||||
}
|
||||
toBrush = fromBrush.lighter(300);
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
QPoint p1(titleRect.x(), titleRect.y() + titleRect.height()/2);
|
||||
QPoint p2(titleRect.right(), titleRect.y() + titleRect.height()/2);
|
||||
QLinearGradient lg(p1, p2);
|
||||
lg.setColorAt(0, fromBrush);
|
||||
lg.setColorAt(1, toBrush);
|
||||
painter->fillRect(titleRect, lg);
|
||||
|
||||
painter->setPen(titlePen);
|
||||
painter->drawText(titleRect, Qt::AlignVCenter, windowTitleFor(widget));
|
||||
decorationRegion ^= Title;
|
||||
}
|
||||
|
||||
return QDecorationDefault::paint(painter, widget, decorationRegion, state);
|
||||
}
|
||||
|
||||
void QDecorationWindows::paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
|
||||
DecorationState state, const QPalette &pal)
|
||||
{
|
||||
QBrush fromBrush, toBrush;
|
||||
QPen titlePen;
|
||||
|
||||
if (widget == qApp->activeWindow() || qApp->activeWindow() == qApp->activePopupWidget()) {
|
||||
fromBrush = pal.brush(QPalette::Highlight);
|
||||
titlePen = pal.color(QPalette::HighlightedText);
|
||||
} else {
|
||||
fromBrush = pal.brush(QPalette::Window);
|
||||
titlePen = pal.color(QPalette::Text);
|
||||
}
|
||||
toBrush = fromBrush.color().lighter(300);
|
||||
|
||||
QRect brect(QDecoration::region(widget, buttonRegion).boundingRect());
|
||||
if (buttonRegion != Close && buttonRegion != Menu)
|
||||
painter->fillRect(brect, toBrush);
|
||||
else
|
||||
painter->fillRect(brect.x() - 2, brect.y(), brect.width() + 4, brect.height(),
|
||||
buttonRegion == Menu ? fromBrush : toBrush);
|
||||
|
||||
int xoff = 1;
|
||||
int yoff = 2;
|
||||
const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff);
|
||||
if (buttonRegion != Menu) {
|
||||
if (state & Normal) {
|
||||
qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(),
|
||||
brect.height() - 4, pal, false, &pal.brush(QPalette::Window));
|
||||
} else if (state & Pressed) {
|
||||
qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(),
|
||||
brect.height() - 4, pal, true, &pal.brush(QPalette::Window));
|
||||
++xoff;
|
||||
++yoff;
|
||||
}
|
||||
} else {
|
||||
xoff = 0;
|
||||
yoff = 2;
|
||||
}
|
||||
|
||||
if (!pm.isNull())
|
||||
painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm);
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_DECORATION_WINDOWS || QT_PLUGIN
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,77 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECORATIONWINDOWS_QWS_H
|
||||
#define QDECORATIONWINDOWS_QWS_H
|
||||
|
||||
#include <QtGui/qdecorationdefault_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if !defined(QT_NO_QWS_DECORATION_WINDOWS) || defined(QT_PLUGIN)
|
||||
|
||||
class Q_GUI_EXPORT QDecorationWindows : public QDecorationDefault
|
||||
{
|
||||
public:
|
||||
QDecorationWindows();
|
||||
virtual ~QDecorationWindows();
|
||||
|
||||
QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
|
||||
bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
|
||||
DecorationState state = Normal);
|
||||
|
||||
protected:
|
||||
void paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
|
||||
DecorationState state, const QPalette &pal);
|
||||
const char **xpmForRegion(int reg);
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_DECORATION_WINDOWS
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDECORATIONWINDOWS_QWS_H
|
@ -1,682 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdirectpainter_qws.h"
|
||||
|
||||
#include "qscreen_qws.h"
|
||||
#include "private/qobject_p.h"
|
||||
#include "private/qapplication_p.h"
|
||||
#include "qwsdisplay_qws.h"
|
||||
#include "qwidget.h"
|
||||
#include "qimage.h"
|
||||
#include <qwsevent_qws.h>
|
||||
#include <private/qwindowsurface_qws_p.h>
|
||||
#include <private/qwsdisplay_qws_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef Q_WS_QWS
|
||||
#ifndef QT_NO_DIRECTPAINTER
|
||||
|
||||
/*!
|
||||
\class QDirectPainter
|
||||
\ingroup painting
|
||||
\ingroup qws
|
||||
|
||||
\brief The QDirectPainter class provides direct access to the
|
||||
underlying hardware in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QDirectPainter allows a client application to reserve a region of
|
||||
the framebuffer and render directly onto the screen. There are two
|
||||
ways of using the QDirectPainter class: You can either reserve a
|
||||
region using the provided static functions, or you can instantiate
|
||||
an object and make use of its more dynamic API.
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\section1 Dynamic Allocation
|
||||
|
||||
By instantiating a QDirectPainter object using the default
|
||||
QDirectPainter::NonReserved surface flag, the client application
|
||||
only gets some control over the reserved region, i.e., it can
|
||||
still render directly onto the screen but the allocated region may
|
||||
change (for example, if a window with a higher focus requests
|
||||
parts of the same region). The currently allocated region can be
|
||||
retrieved using the allocatedRegion() function, while the
|
||||
requestedRegion() function returns the originally reserved
|
||||
region.
|
||||
|
||||
|
||||
\section1 Static Allocation
|
||||
|
||||
|
||||
Using the static approach, the client application gets complete
|
||||
control over the reserved region, i.e., the affected region will
|
||||
never be modified by the screen driver.
|
||||
|
||||
To create a static region, pass the QDirectPainter::Reserved
|
||||
surface flag to the constructor. After the reserved region is
|
||||
reported through regionChanged(), the allocated region will not
|
||||
change, unless setRegion() is called.
|
||||
|
||||
If QDirectPainter::ReservedSynchronous is passed to the
|
||||
constructor, calls to setRegion() will block until the region is
|
||||
reserved, meaning that allocatedRegion() will be available immediately.
|
||||
Note that in the current version setRegion() will cause the application
|
||||
event loop to be entered, potentially causing reentrancy issues.
|
||||
|
||||
\section1 Rendering
|
||||
|
||||
To draw on a given region, the application must first get hold of
|
||||
a pointer to the framebuffer. In most cases, this pointer can be
|
||||
retrieved using the QDirectPainter::frameBuffer() function. But
|
||||
note that if the current screen has subscreens, you must query the
|
||||
screen driver instead to identify the correct subscreen. A pointer
|
||||
to the current screen driver can always be retrieved using the
|
||||
static QScreen::instance() function. Then use QScreen's \l
|
||||
{QScreen::}{subScreenIndexAt()} and \l {QScreen::}{subScreens()}
|
||||
functions to access the correct subscreen, and the subscreen's \l
|
||||
{QScreen::}{base()} function to retrieve a pointer to the
|
||||
framebuffer.
|
||||
|
||||
Depending on the hardware, it might be necessary to lock the
|
||||
framebuffer for exclusive use while writing to it. This is
|
||||
possible using the lock() and unlock() functions. Note that
|
||||
calling lock() will prevent all other applications from working
|
||||
until unlock() is called.
|
||||
|
||||
In addition, QDirectPainter provides several functions returning
|
||||
information about the framebuffer: the linestep() function returns
|
||||
the length (in bytes) of each scanline of the framebuffer while
|
||||
the screenDepth(), screenWidth() and screenHeight() function
|
||||
return the screen metrics.
|
||||
|
||||
\sa QScreen, QWSEmbedWidget, {Qt for Embedded Linux Architecture}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDirectPainter::SurfaceFlag
|
||||
|
||||
This enum describes the behavior of the region reserved by this
|
||||
QDirectPainter object.
|
||||
|
||||
\value NonReserved The allocated region may change, e.g., if a
|
||||
window with a higher focus requests parts of the same region. See
|
||||
also \l {Dynamic Allocation}.
|
||||
|
||||
\value Reserved The allocated region will never change. See also
|
||||
\l {Static Allocation}.
|
||||
|
||||
\value ReservedSynchronous The allocated region will never change and
|
||||
each function that changes the allocated region will be blocking.
|
||||
|
||||
\sa allocatedRegion()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRegion QDirectPainter::region()
|
||||
\obsolete
|
||||
|
||||
Use QDirectPainter::allocatedRegion() instead.
|
||||
*/
|
||||
|
||||
static inline QScreen *getPrimaryScreen()
|
||||
{
|
||||
QScreen *screen = QScreen::instance();
|
||||
if (!screen->base()) {
|
||||
QList<QScreen*> subScreens = screen->subScreens();
|
||||
if (subScreens.size() < 1)
|
||||
return 0;
|
||||
screen = subScreens.at(0);
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
static inline QSize screenS()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return QSize();
|
||||
return QSize(screen->width(), screen->height());
|
||||
}
|
||||
|
||||
static inline QSize devS()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return QSize();
|
||||
return QSize(screen->deviceWidth(), screen->deviceHeight());
|
||||
}
|
||||
|
||||
|
||||
class QDirectPainterPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QDirectPainter);
|
||||
public:
|
||||
|
||||
QDirectPainterPrivate() : surface(0), seenRegion(false) {}
|
||||
|
||||
~QDirectPainterPrivate() {
|
||||
if (QPaintDevice::qwsDisplay()) { // make sure not in QApplication destructor
|
||||
qApp->d_func()->directPainters->remove(surface->windowId());
|
||||
surface->setGeometry(QRect());
|
||||
}
|
||||
delete surface;
|
||||
}
|
||||
|
||||
QWSDirectPainterSurface *surface;
|
||||
QRegion requested_region;
|
||||
|
||||
static QDirectPainter *staticPainter;
|
||||
bool seenRegion;
|
||||
};
|
||||
|
||||
QDirectPainter *QDirectPainterPrivate::staticPainter = 0;
|
||||
|
||||
void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type)
|
||||
{
|
||||
QDirectPainterPrivate *d = dp->d_func();
|
||||
|
||||
QRegion r = alloc;
|
||||
QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize screenSize(screen->width(), screen->height());
|
||||
r = screen->mapToDevice(r, screenSize);
|
||||
}
|
||||
if (type == QWSRegionEvent::Allocation) {
|
||||
d->surface->setClipRegion(alloc);
|
||||
d->seenRegion = true;
|
||||
if (dp != QDirectPainterPrivate::staticPainter) {
|
||||
if (!d->surface->flushingRegionEvents) // recursion guard
|
||||
dp->regionChanged(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
void qt_directpainter_embedevent(QDirectPainter *dp, const QWSEmbedEvent *event)
|
||||
{
|
||||
if (event->type | QWSEmbedEvent::Region) {
|
||||
QScreen *screen = dp->d_func()->surface->screen();
|
||||
QRegion r = event->region;
|
||||
if (screen->isTransformed()) {
|
||||
const QSize screenSize(screen->width(), screen->height());
|
||||
r = screen->mapToDevice(r, screenSize);
|
||||
}
|
||||
dp->setRegion(r);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Constructs a QDirectPainter object with the given \a parent and
|
||||
surface \a flag.
|
||||
*/
|
||||
QDirectPainter::QDirectPainter(QObject *parent, SurfaceFlag flag)
|
||||
:QObject(*new QDirectPainterPrivate, parent)
|
||||
{
|
||||
Q_D(QDirectPainter);
|
||||
d->surface = new QWSDirectPainterSurface(true, flag);
|
||||
|
||||
if (flag != NonReserved)
|
||||
d->surface->setReserved();
|
||||
|
||||
QApplicationPrivate *ad = qApp->d_func();
|
||||
if (!ad->directPainters)
|
||||
ad->directPainters = new QMap<WId, QDirectPainter*>;
|
||||
ad->directPainters->insert(d->surface->windowId(), this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QDirectPainter object, releasing the reserved region.
|
||||
|
||||
\sa allocatedRegion()
|
||||
*/
|
||||
QDirectPainter::~QDirectPainter()
|
||||
{
|
||||
/* should not be necessary
|
||||
if (this == QDirectPainterPrivate::staticPainter)
|
||||
QDirectPainterPrivate::staticPainter = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDirectPainter::setGeometry(const QRect &rectangle)
|
||||
\since 4.2
|
||||
|
||||
Request to reserve the given \a rectangle of the framebuffer.
|
||||
|
||||
Note that the actually allocated region might differ from the
|
||||
requested one, e.g., if the given region overlaps with the
|
||||
region of another QDirectPainter object.
|
||||
|
||||
\sa geometry(), allocatedRegion(), setRegion()
|
||||
*/
|
||||
void QDirectPainter::setGeometry(const QRect &rect)
|
||||
{
|
||||
setRegion(rect);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Returns the bounding rectangle of the requested region.
|
||||
|
||||
\sa setGeometry(), requestedRegion()
|
||||
*/
|
||||
QRect QDirectPainter::geometry() const
|
||||
{
|
||||
Q_D(const QDirectPainter);
|
||||
return d->requested_region.boundingRect();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Requests to reserve the given \a region of the framebuffer.
|
||||
|
||||
Note that the actually allocated region might differ from the
|
||||
requested one, e.g., if the given region overlaps with the region
|
||||
of another QDirectPainter object.
|
||||
|
||||
\sa requestedRegion(), allocatedRegion(), {Dynamic Allocation}
|
||||
*/
|
||||
void QDirectPainter::setRegion(const QRegion ®ion)
|
||||
{
|
||||
Q_D(QDirectPainter);
|
||||
d->requested_region = region;
|
||||
|
||||
const QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
|
||||
const QRegion r = screen->mapFromDevice(region, devSize);
|
||||
d->surface->setRegion(r);
|
||||
} else {
|
||||
d->surface->setRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Returns the region requested by this QDirectPainter.
|
||||
|
||||
Note that if the QDirectPainter::Reserved flag is set, the region
|
||||
returned by this function will always be equivalent to the region
|
||||
returned by the allocatedRegion() function. Otherwise they might
|
||||
differ (see \l {Dynamic Allocation} for details).
|
||||
|
||||
\sa geometry(), setRegion(), allocatedRegion()
|
||||
*/
|
||||
QRegion QDirectPainter::requestedRegion() const
|
||||
{
|
||||
Q_D(const QDirectPainter);
|
||||
return d->requested_region;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Returns the currently reserved region.
|
||||
|
||||
Note that if the QDirectPainter::Reserved flag is set, the region
|
||||
returned by this function will always be equivalent to the region
|
||||
returned by the requestedRegion() function. Otherwise they might
|
||||
differ (see \l {Dynamic Allocation} for details).
|
||||
|
||||
\sa requestedRegion(), geometry()
|
||||
*/
|
||||
QRegion QDirectPainter::allocatedRegion() const
|
||||
{
|
||||
Q_D(const QDirectPainter);
|
||||
const QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize screenSize(screen->width(), screen->height());
|
||||
return screen->mapToDevice(d->surface->region(), screenSize);
|
||||
} else {
|
||||
return d->surface->region();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Returns the window system identifier of the widget.
|
||||
*/
|
||||
WId QDirectPainter::winId() const
|
||||
{
|
||||
Q_D(const QDirectPainter);
|
||||
return d->surface->windowId();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDirectPainter::regionChanged(const QRegion &newRegion)
|
||||
\since 4.2
|
||||
|
||||
This function is called when the allocated region changes.
|
||||
|
||||
This function is not called for region changes that happen while the
|
||||
startPainting() function is executing.
|
||||
|
||||
Note that the given region, \a newRegion, is not guaranteed to be correct at the
|
||||
time you access the display. To prevent reentrancy problems you should
|
||||
always call startPainting() before updating the display and then use
|
||||
allocatedRegion() to retrieve the correct region.
|
||||
|
||||
\sa allocatedRegion(), startPainting(), {Dynamic Allocation}
|
||||
*/
|
||||
void QDirectPainter::regionChanged(const QRegion ®ion)
|
||||
{
|
||||
Q_UNUSED(region);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Call this function before you start updating the pixels in the
|
||||
allocated region. The hardware will be notified, if necessary,
|
||||
that you are about to start painting operations.
|
||||
|
||||
Set \a lockDisplay if you want startPainting() and endPainting()
|
||||
to lock() and unlock() the display automatically.
|
||||
|
||||
Note that for a NonReserved direct painter, you must call
|
||||
allocatedRegion() after calling this function, since the allocated
|
||||
region is only guaranteed to be correct after this function has
|
||||
returned.
|
||||
|
||||
The regionChanged() function will not be called between startPainting()
|
||||
and endPainting().
|
||||
|
||||
\sa endPainting(), flush()
|
||||
*/
|
||||
void QDirectPainter::startPainting(bool lockDisplay)
|
||||
{
|
||||
Q_D(QDirectPainter);
|
||||
d->surface->setLocking(lockDisplay);
|
||||
|
||||
const QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
|
||||
const QRegion r = screen->mapFromDevice(d->surface->region(), devSize);
|
||||
d->surface->beginPaint(r);
|
||||
} else {
|
||||
d->surface->beginPaint(d->surface->region());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Call this function when you are done updating the screen. It will
|
||||
notify the hardware, if necessary, that your painting operations
|
||||
have ended.
|
||||
*/
|
||||
void QDirectPainter::endPainting()
|
||||
{
|
||||
Q_D(QDirectPainter);
|
||||
|
||||
const QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
|
||||
const QRegion r = screen->mapFromDevice(d->surface->region(), devSize);
|
||||
d->surface->endPaint(r);
|
||||
} else {
|
||||
d->surface->endPaint(d->surface->region());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.3
|
||||
\overload
|
||||
|
||||
This function will automatically call flush() to flush the
|
||||
\a region to the display before notifying the hardware, if
|
||||
necessary, that painting operations have ended.
|
||||
*/
|
||||
void QDirectPainter::endPainting(const QRegion ®ion)
|
||||
{
|
||||
endPainting();
|
||||
flush(region);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.3
|
||||
|
||||
Flushes the \a region onto the screen.
|
||||
*/
|
||||
void QDirectPainter::flush(const QRegion ®ion)
|
||||
{
|
||||
Q_D(QDirectPainter);
|
||||
|
||||
const QScreen *screen = d->surface->screen();
|
||||
if (screen->isTransformed()) {
|
||||
const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
|
||||
const QRegion r = screen->mapFromDevice(region, devSize);
|
||||
d->surface->flush(0, r, QPoint());
|
||||
} else {
|
||||
d->surface->flush(0, region, QPoint());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Raises the reserved region to the top of the widget stack.
|
||||
|
||||
After this call the reserved region will be visually in front of
|
||||
any overlapping widgets.
|
||||
|
||||
\sa lower(), requestedRegion()
|
||||
*/
|
||||
void QDirectPainter::raise()
|
||||
{
|
||||
QWidget::qwsDisplay()->setAltitude(winId(),QWSChangeAltitudeCommand::Raise);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Lowers the reserved region to the bottom of the widget stack.
|
||||
|
||||
After this call the reserved region will be visually behind (and
|
||||
therefore obscured by) any overlapping widgets.
|
||||
|
||||
\sa raise(), requestedRegion()
|
||||
*/
|
||||
void QDirectPainter::lower()
|
||||
{
|
||||
QWidget::qwsDisplay()->setAltitude(winId(),QWSChangeAltitudeCommand::Lower);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn QRegion QDirectPainter::reserveRegion(const QRegion ®ion)
|
||||
|
||||
Attempts to reserve the \a region and returns the region that is
|
||||
actually reserved.
|
||||
|
||||
This function also releases the previously reserved region if
|
||||
any. If not released explicitly, the region will be released on
|
||||
application exit.
|
||||
|
||||
\sa allocatedRegion(), {Static Allocation}
|
||||
|
||||
\obsolete
|
||||
|
||||
Construct a QDirectPainter using QDirectPainter::ReservedSynchronous instead.
|
||||
*/
|
||||
QRegion QDirectPainter::reserveRegion(const QRegion ®)
|
||||
{
|
||||
if (!QDirectPainterPrivate::staticPainter)
|
||||
QDirectPainterPrivate::staticPainter = new QDirectPainter(qApp, ReservedSynchronous);
|
||||
|
||||
QDirectPainter *dp = QDirectPainterPrivate::staticPainter;
|
||||
dp->setRegion(reg);
|
||||
|
||||
return dp->allocatedRegion();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to the beginning of the display memory.
|
||||
|
||||
Note that it is the application's responsibility to limit itself
|
||||
to modifying only the reserved region.
|
||||
|
||||
Do not use this pointer if the current screen has subscreens,
|
||||
query the screen driver instead: A pointer to the current screen
|
||||
driver can always be retrieved using the static
|
||||
QScreen::instance() function. Then use QScreen's \l
|
||||
{QScreen::}{subScreenIndexAt()} and \l {QScreen::}{subScreens()}
|
||||
functions to access the correct subscreen, and the subscreen's \l
|
||||
{QScreen::}{base()} function to retrieve a pointer to the
|
||||
framebuffer.
|
||||
|
||||
\sa requestedRegion(), allocatedRegion(), linestep()
|
||||
*/
|
||||
uchar* QDirectPainter::frameBuffer()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return 0;
|
||||
return screen->base();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Returns the reserved region.
|
||||
|
||||
\sa reserveRegion(), frameBuffer()
|
||||
|
||||
\obsolete
|
||||
|
||||
Use allocatedRegion() instead.
|
||||
*/
|
||||
QRegion QDirectPainter::reservedRegion()
|
||||
{
|
||||
return QDirectPainterPrivate::staticPainter
|
||||
? QDirectPainterPrivate::staticPainter->allocatedRegion() : QRegion();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the bit depth of the display.
|
||||
|
||||
\sa screenHeight(), screenWidth()
|
||||
*/
|
||||
int QDirectPainter::screenDepth()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return 0;
|
||||
return screen->depth();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the width of the display in pixels.
|
||||
|
||||
\sa screenHeight(), screenDepth()
|
||||
*/
|
||||
int QDirectPainter::screenWidth()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return 0;
|
||||
return screen->deviceWidth();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the height of the display in pixels.
|
||||
|
||||
\sa screenWidth(), screenDepth()
|
||||
*/
|
||||
int QDirectPainter::screenHeight()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return 0;
|
||||
return screen->deviceHeight();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the length (in bytes) of each scanline of the framebuffer.
|
||||
|
||||
\sa frameBuffer()
|
||||
*/
|
||||
int QDirectPainter::linestep()
|
||||
{
|
||||
QScreen *screen = getPrimaryScreen();
|
||||
if (!screen)
|
||||
return 0;
|
||||
return screen->linestep();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Locks access to the framebuffer.
|
||||
|
||||
Note that calling this function will prevent all other
|
||||
applications from updating the display until unlock() is called.
|
||||
|
||||
\sa unlock()
|
||||
*/
|
||||
void QDirectPainter::lock()
|
||||
{
|
||||
QWSDisplay::grab(true);
|
||||
}
|
||||
/*!
|
||||
Unlocks the lock on the framebuffer (set using the lock()
|
||||
function), allowing other applications to access the screen.
|
||||
|
||||
\sa lock()
|
||||
*/
|
||||
void QDirectPainter::unlock()
|
||||
{
|
||||
QWSDisplay::ungrab();
|
||||
}
|
||||
|
||||
#endif //QT_NO_DIRECTPAINTER
|
||||
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,112 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDIRECTPAINTER_QWS_H
|
||||
#define QDIRECTPAINTER_QWS_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qregion.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_DIRECTPAINTER
|
||||
class QDirectPainterPrivate;
|
||||
class QWSEmbedEvent;
|
||||
|
||||
class Q_GUI_EXPORT QDirectPainter : public QObject {
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QDirectPainter)
|
||||
public:
|
||||
|
||||
enum SurfaceFlag { NonReserved = 0,
|
||||
Reserved = 1,
|
||||
ReservedSynchronous = 3 };
|
||||
|
||||
explicit QDirectPainter(QObject *parentObject = 0, SurfaceFlag flag = NonReserved);
|
||||
~QDirectPainter();
|
||||
|
||||
void setRegion(const QRegion&);
|
||||
QRegion requestedRegion() const;
|
||||
QRegion allocatedRegion() const;
|
||||
|
||||
void setGeometry(const QRect&);
|
||||
QRect geometry() const;
|
||||
|
||||
WId winId() const;
|
||||
virtual void regionChanged(const QRegion &exposedRegion);
|
||||
|
||||
void startPainting(bool lockDisplay = true);
|
||||
void endPainting();
|
||||
void endPainting(const QRegion ®ion);
|
||||
void flush(const QRegion ®ion);
|
||||
|
||||
void raise();
|
||||
void lower();
|
||||
|
||||
|
||||
static QRegion reserveRegion(const QRegion&);
|
||||
static QRegion reservedRegion();
|
||||
static QRegion region() { return reservedRegion(); }
|
||||
|
||||
static uchar* frameBuffer();
|
||||
static int screenDepth();
|
||||
static int screenWidth();
|
||||
static int screenHeight();
|
||||
static int linestep();
|
||||
|
||||
static void lock();
|
||||
static void unlock();
|
||||
private:
|
||||
friend void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type);
|
||||
friend void qt_directpainter_embedevent(QDirectPainter*, const QWSEmbedEvent*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDIRECTPAINTER_QWS_H
|
@ -1,806 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSKEYBOARDHANDLER_DEFAULTMAP_H
|
||||
#define QWSKEYBOARDHANDLER_DEFAULTMAP_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.
|
||||
//
|
||||
|
||||
// no QT_BEGIN_NAMESPACE, since we include it internally...
|
||||
|
||||
const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
|
||||
{ 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 },
|
||||
{ 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 },
|
||||
{ 2, 0x0021, 0x00000021, 0x01, 0x00, 0x0000 },
|
||||
{ 3, 0x0032, 0x00000032, 0x00, 0x00, 0x0000 },
|
||||
{ 3, 0x0040, 0x00000040, 0x01, 0x00, 0x0000 },
|
||||
{ 3, 0x0040, 0x00000040, 0x02, 0x00, 0x0000 },
|
||||
{ 4, 0x0033, 0x00000033, 0x00, 0x00, 0x0000 },
|
||||
{ 4, 0x0023, 0x00000023, 0x01, 0x00, 0x0000 },
|
||||
{ 4, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
|
||||
{ 5, 0x0034, 0x00000034, 0x00, 0x00, 0x0000 },
|
||||
{ 5, 0x0024, 0x00000024, 0x01, 0x00, 0x0000 },
|
||||
{ 5, 0x0024, 0x00000024, 0x02, 0x00, 0x0000 },
|
||||
{ 5, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
|
||||
{ 6, 0x0035, 0x00000035, 0x00, 0x00, 0x0000 },
|
||||
{ 6, 0x0025, 0x00000025, 0x01, 0x00, 0x0000 },
|
||||
{ 6, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
|
||||
{ 7, 0x0036, 0x00000036, 0x00, 0x00, 0x0000 },
|
||||
{ 7, 0x005e, 0x0000005e, 0x01, 0x00, 0x0000 },
|
||||
{ 7, 0x005e, 0x01001252, 0x02, 0x01, 0x0000 },
|
||||
{ 7, 0x005e, 0x0400005e, 0x04, 0x00, 0x0000 },
|
||||
{ 8, 0x0037, 0x00000037, 0x00, 0x00, 0x0000 },
|
||||
{ 8, 0x0026, 0x00000026, 0x01, 0x00, 0x0000 },
|
||||
{ 8, 0x007b, 0x0000007b, 0x02, 0x00, 0x0000 },
|
||||
{ 8, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
|
||||
{ 9, 0x0038, 0x00000038, 0x00, 0x00, 0x0000 },
|
||||
{ 9, 0x002a, 0x0000002a, 0x01, 0x00, 0x0000 },
|
||||
{ 9, 0x005b, 0x0000005b, 0x02, 0x00, 0x0000 },
|
||||
{ 9, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
|
||||
{ 10, 0x0039, 0x00000039, 0x00, 0x00, 0x0000 },
|
||||
{ 10, 0x0028, 0x00000028, 0x01, 0x00, 0x0000 },
|
||||
{ 10, 0x005d, 0x0000005d, 0x02, 0x00, 0x0000 },
|
||||
{ 11, 0x0030, 0x00000030, 0x00, 0x00, 0x0000 },
|
||||
{ 11, 0x0029, 0x00000029, 0x01, 0x00, 0x0000 },
|
||||
{ 11, 0x007d, 0x0000007d, 0x02, 0x00, 0x0000 },
|
||||
{ 12, 0x002d, 0x0000002d, 0x00, 0x00, 0x0000 },
|
||||
{ 12, 0x005f, 0x0000005f, 0x01, 0x00, 0x0000 },
|
||||
{ 12, 0x005c, 0x0000005c, 0x02, 0x00, 0x0000 },
|
||||
{ 12, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
|
||||
{ 12, 0x005f, 0x0400005f, 0x05, 0x00, 0x0000 },
|
||||
{ 13, 0x003d, 0x0000003d, 0x00, 0x00, 0x0000 },
|
||||
{ 13, 0x002b, 0x0000002b, 0x01, 0x00, 0x0000 },
|
||||
{ 14, 0xffff, 0x01000003, 0x00, 0x00, 0x0000 },
|
||||
{ 14, 0xffff, 0x01000000, 0x0c, 0x08, 0x0300 },
|
||||
{ 15, 0xffff, 0x01000001, 0x00, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x00000051, 0x00, 0x00, 0x0000 },
|
||||
{ 16, 0x0051, 0x00000051, 0x01, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x00000051, 0x02, 0x00, 0x0000 },
|
||||
{ 16, 0x0051, 0x00000051, 0x03, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x04000051, 0x04, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x04000051, 0x05, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x04000051, 0x06, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x04000051, 0x07, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x08000051, 0x08, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x08000051, 0x09, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x08000051, 0x0a, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x08000051, 0x0b, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x0c000051, 0x0c, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x0c000051, 0x0d, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x0c000051, 0x0e, 0x00, 0x0000 },
|
||||
{ 16, 0x0071, 0x0c000051, 0x0f, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x00000057, 0x00, 0x00, 0x0000 },
|
||||
{ 17, 0x0057, 0x00000057, 0x01, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x00000057, 0x02, 0x00, 0x0000 },
|
||||
{ 17, 0x0057, 0x00000057, 0x03, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x04000057, 0x04, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x04000057, 0x05, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x04000057, 0x06, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x04000057, 0x07, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x08000057, 0x08, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x08000057, 0x09, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x08000057, 0x0a, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x08000057, 0x0b, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x0c000057, 0x0c, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x0c000057, 0x0d, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x0c000057, 0x0e, 0x00, 0x0000 },
|
||||
{ 17, 0x0077, 0x0c000057, 0x0f, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x00000045, 0x00, 0x00, 0x0000 },
|
||||
{ 18, 0x0045, 0x00000045, 0x01, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x00000045, 0x02, 0x00, 0x0000 },
|
||||
{ 18, 0x0045, 0x00000045, 0x03, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x04000045, 0x04, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x04000045, 0x05, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x04000045, 0x06, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x04000045, 0x07, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x08000045, 0x08, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x08000045, 0x09, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x08000045, 0x0a, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x08000045, 0x0b, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x0c000045, 0x0c, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x0c000045, 0x0d, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x0c000045, 0x0e, 0x00, 0x0000 },
|
||||
{ 18, 0x0065, 0x0c000045, 0x0f, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x00000052, 0x00, 0x00, 0x0000 },
|
||||
{ 19, 0x0052, 0x00000052, 0x01, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x00000052, 0x02, 0x00, 0x0000 },
|
||||
{ 19, 0x0052, 0x00000052, 0x03, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x04000052, 0x04, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x04000052, 0x05, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x04000052, 0x06, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x04000052, 0x07, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x08000052, 0x08, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x08000052, 0x09, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x08000052, 0x0a, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x08000052, 0x0b, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x0c000052, 0x0c, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x0c000052, 0x0d, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x0c000052, 0x0e, 0x00, 0x0000 },
|
||||
{ 19, 0x0072, 0x0c000052, 0x0f, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x00000054, 0x00, 0x00, 0x0000 },
|
||||
{ 20, 0x0054, 0x00000054, 0x01, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x00000054, 0x02, 0x00, 0x0000 },
|
||||
{ 20, 0x0054, 0x00000054, 0x03, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x04000054, 0x04, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x04000054, 0x05, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x04000054, 0x06, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x04000054, 0x07, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x08000054, 0x08, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x08000054, 0x09, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x08000054, 0x0a, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x08000054, 0x0b, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x0c000054, 0x0c, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x0c000054, 0x0d, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x0c000054, 0x0e, 0x00, 0x0000 },
|
||||
{ 20, 0x0074, 0x0c000054, 0x0f, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x00000059, 0x00, 0x00, 0x0000 },
|
||||
{ 21, 0x0059, 0x00000059, 0x01, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x00000059, 0x02, 0x00, 0x0000 },
|
||||
{ 21, 0x0059, 0x00000059, 0x03, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x04000059, 0x04, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x04000059, 0x05, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x04000059, 0x06, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x04000059, 0x07, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x08000059, 0x08, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x08000059, 0x09, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x08000059, 0x0a, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x08000059, 0x0b, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x0c000059, 0x0c, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x0c000059, 0x0d, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x0c000059, 0x0e, 0x00, 0x0000 },
|
||||
{ 21, 0x0079, 0x0c000059, 0x0f, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x00000055, 0x00, 0x00, 0x0000 },
|
||||
{ 22, 0x0055, 0x00000055, 0x01, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x00000055, 0x02, 0x00, 0x0000 },
|
||||
{ 22, 0x0055, 0x00000055, 0x03, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x04000055, 0x04, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x04000055, 0x05, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x04000055, 0x06, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x04000055, 0x07, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x08000055, 0x08, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x08000055, 0x09, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x08000055, 0x0a, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x08000055, 0x0b, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x0c000055, 0x0c, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x0c000055, 0x0d, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x0c000055, 0x0e, 0x00, 0x0000 },
|
||||
{ 22, 0x0075, 0x0c000055, 0x0f, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x00000049, 0x00, 0x00, 0x0000 },
|
||||
{ 23, 0x0049, 0x00000049, 0x01, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x00000049, 0x02, 0x00, 0x0000 },
|
||||
{ 23, 0x0049, 0x00000049, 0x03, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x04000049, 0x04, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x04000049, 0x05, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x04000049, 0x06, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x04000049, 0x07, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x08000049, 0x08, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x08000049, 0x09, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x08000049, 0x0a, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x08000049, 0x0b, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x0c000049, 0x0c, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x0c000049, 0x0d, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x0c000049, 0x0e, 0x00, 0x0000 },
|
||||
{ 23, 0x0069, 0x0c000049, 0x0f, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0000004f, 0x00, 0x00, 0x0000 },
|
||||
{ 24, 0x004f, 0x0000004f, 0x01, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0000004f, 0x02, 0x00, 0x0000 },
|
||||
{ 24, 0x004f, 0x0000004f, 0x03, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0400004f, 0x04, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0400004f, 0x05, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0400004f, 0x06, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0400004f, 0x07, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0800004f, 0x08, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0800004f, 0x09, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0800004f, 0x0a, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0800004f, 0x0b, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0c00004f, 0x0c, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0c00004f, 0x0d, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0c00004f, 0x0e, 0x00, 0x0000 },
|
||||
{ 24, 0x006f, 0x0c00004f, 0x0f, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x00000050, 0x00, 0x00, 0x0000 },
|
||||
{ 25, 0x0050, 0x00000050, 0x01, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x00000050, 0x02, 0x00, 0x0000 },
|
||||
{ 25, 0x0050, 0x00000050, 0x03, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x04000050, 0x04, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x04000050, 0x05, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x04000050, 0x06, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x04000050, 0x07, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x08000050, 0x08, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x08000050, 0x09, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x08000050, 0x0a, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x08000050, 0x0b, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x0c000050, 0x0c, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x0c000050, 0x0d, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x0c000050, 0x0e, 0x00, 0x0000 },
|
||||
{ 25, 0x0070, 0x0c000050, 0x0f, 0x00, 0x0000 },
|
||||
{ 26, 0x005b, 0x0000005b, 0x00, 0x00, 0x0000 },
|
||||
{ 26, 0x007b, 0x0000007b, 0x01, 0x00, 0x0000 },
|
||||
{ 26, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
|
||||
{ 27, 0x005d, 0x0000005d, 0x00, 0x00, 0x0000 },
|
||||
{ 27, 0x007d, 0x0000007d, 0x01, 0x00, 0x0000 },
|
||||
{ 27, 0x007e, 0x0000007e, 0x02, 0x00, 0x0000 },
|
||||
{ 27, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
|
||||
{ 28, 0xffff, 0x01000004, 0x00, 0x00, 0x0000 },
|
||||
{ 28, 0x006d, 0x0c00004d, 0x08, 0x00, 0x0000 },
|
||||
{ 29, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
|
||||
{ 30, 0x0061, 0x00000041, 0x00, 0x00, 0x0000 },
|
||||
{ 30, 0x0041, 0x00000041, 0x01, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x00000041, 0x02, 0x00, 0x0000 },
|
||||
{ 30, 0x0041, 0x00000041, 0x03, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x04000041, 0x04, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x04000041, 0x05, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x04000041, 0x06, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x04000041, 0x07, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x08000041, 0x08, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x08000041, 0x09, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x08000041, 0x0a, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x08000041, 0x0b, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x0c000041, 0x0c, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x0c000041, 0x0d, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x0c000041, 0x0e, 0x00, 0x0000 },
|
||||
{ 30, 0x0061, 0x0c000041, 0x0f, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x00000053, 0x00, 0x00, 0x0000 },
|
||||
{ 31, 0x0053, 0x00000053, 0x01, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x00000053, 0x02, 0x00, 0x0000 },
|
||||
{ 31, 0x0053, 0x00000053, 0x03, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x04000053, 0x04, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x04000053, 0x05, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x04000053, 0x06, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x04000053, 0x07, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x08000053, 0x08, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x08000053, 0x09, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x08000053, 0x0a, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x08000053, 0x0b, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x0c000053, 0x0c, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x0c000053, 0x0d, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x0c000053, 0x0e, 0x00, 0x0000 },
|
||||
{ 31, 0x0073, 0x0c000053, 0x0f, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x00000044, 0x00, 0x00, 0x0000 },
|
||||
{ 32, 0x0044, 0x00000044, 0x01, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x00000044, 0x02, 0x00, 0x0000 },
|
||||
{ 32, 0x0044, 0x00000044, 0x03, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x04000044, 0x04, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x04000044, 0x05, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x04000044, 0x06, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x04000044, 0x07, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x08000044, 0x08, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x08000044, 0x09, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x08000044, 0x0a, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x08000044, 0x0b, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x0c000044, 0x0c, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x0c000044, 0x0d, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x0c000044, 0x0e, 0x00, 0x0000 },
|
||||
{ 32, 0x0064, 0x0c000044, 0x0f, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x00000046, 0x00, 0x00, 0x0000 },
|
||||
{ 33, 0x0046, 0x00000046, 0x01, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x00000046, 0x02, 0x00, 0x0000 },
|
||||
{ 33, 0x0046, 0x00000046, 0x03, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x04000046, 0x04, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x04000046, 0x05, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x04000046, 0x06, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x04000046, 0x07, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x08000046, 0x08, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x08000046, 0x09, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x08000046, 0x0a, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x08000046, 0x0b, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x0c000046, 0x0c, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x0c000046, 0x0d, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x0c000046, 0x0e, 0x00, 0x0000 },
|
||||
{ 33, 0x0066, 0x0c000046, 0x0f, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x00000047, 0x00, 0x00, 0x0000 },
|
||||
{ 34, 0x0047, 0x00000047, 0x01, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x00000047, 0x02, 0x00, 0x0000 },
|
||||
{ 34, 0x0047, 0x00000047, 0x03, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x04000047, 0x05, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x04000047, 0x06, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x04000047, 0x07, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x08000047, 0x08, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x08000047, 0x09, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x08000047, 0x0a, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x08000047, 0x0b, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x0c000047, 0x0c, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x0c000047, 0x0d, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x0c000047, 0x0e, 0x00, 0x0000 },
|
||||
{ 34, 0x0067, 0x0c000047, 0x0f, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x00000048, 0x00, 0x00, 0x0000 },
|
||||
{ 35, 0x0048, 0x00000048, 0x01, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x00000048, 0x02, 0x00, 0x0000 },
|
||||
{ 35, 0x0048, 0x00000048, 0x03, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x04000048, 0x04, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x04000048, 0x05, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x04000048, 0x06, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x04000048, 0x07, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x08000048, 0x08, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x08000048, 0x09, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x08000048, 0x0a, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x08000048, 0x0b, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x0c000048, 0x0c, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x0c000048, 0x0d, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x0c000048, 0x0e, 0x00, 0x0000 },
|
||||
{ 35, 0x0068, 0x0c000048, 0x0f, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0000004a, 0x00, 0x00, 0x0000 },
|
||||
{ 36, 0x004a, 0x0000004a, 0x01, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0000004a, 0x02, 0x00, 0x0000 },
|
||||
{ 36, 0x004a, 0x0000004a, 0x03, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0400004a, 0x04, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0400004a, 0x05, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0400004a, 0x06, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0400004a, 0x07, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0800004a, 0x08, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0800004a, 0x09, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0800004a, 0x0a, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0800004a, 0x0b, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0c00004a, 0x0c, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0c00004a, 0x0d, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0c00004a, 0x0e, 0x00, 0x0000 },
|
||||
{ 36, 0x006a, 0x0c00004a, 0x0f, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0000004b, 0x00, 0x00, 0x0000 },
|
||||
{ 37, 0x004b, 0x0000004b, 0x01, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0000004b, 0x02, 0x00, 0x0000 },
|
||||
{ 37, 0x004b, 0x0000004b, 0x03, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0400004b, 0x04, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0400004b, 0x05, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0400004b, 0x06, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0400004b, 0x07, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0800004b, 0x08, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0800004b, 0x09, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0800004b, 0x0a, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0800004b, 0x0b, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0c00004b, 0x0c, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0c00004b, 0x0d, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0c00004b, 0x0e, 0x00, 0x0000 },
|
||||
{ 37, 0x006b, 0x0c00004b, 0x0f, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0000004c, 0x00, 0x00, 0x0000 },
|
||||
{ 38, 0x004c, 0x0000004c, 0x01, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0000004c, 0x02, 0x00, 0x0000 },
|
||||
{ 38, 0x004c, 0x0000004c, 0x03, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0400004c, 0x04, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0400004c, 0x05, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0400004c, 0x06, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0400004c, 0x07, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0800004c, 0x08, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0800004c, 0x09, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0800004c, 0x0a, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0800004c, 0x0b, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0c00004c, 0x0c, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0c00004c, 0x0d, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0c00004c, 0x0e, 0x00, 0x0000 },
|
||||
{ 38, 0x006c, 0x0c00004c, 0x0f, 0x00, 0x0000 },
|
||||
{ 39, 0x003b, 0x0000003b, 0x00, 0x00, 0x0000 },
|
||||
{ 39, 0x003a, 0x0000003a, 0x01, 0x00, 0x0000 },
|
||||
{ 40, 0x0027, 0x00000027, 0x00, 0x00, 0x0000 },
|
||||
{ 40, 0x0022, 0x00000022, 0x01, 0x00, 0x0000 },
|
||||
{ 40, 0x0027, 0x01001251, 0x02, 0x01, 0x0000 },
|
||||
{ 40, 0x0022, 0x01001257, 0x03, 0x01, 0x0000 },
|
||||
{ 40, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
|
||||
{ 41, 0x0060, 0x00000060, 0x00, 0x00, 0x0000 },
|
||||
{ 41, 0x007e, 0x0000007e, 0x01, 0x00, 0x0000 },
|
||||
{ 41, 0x0060, 0x01001250, 0x02, 0x01, 0x0000 },
|
||||
{ 41, 0x007e, 0x01001253, 0x03, 0x01, 0x0000 },
|
||||
{ 42, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
|
||||
{ 43, 0x005c, 0x0000005c, 0x00, 0x00, 0x0000 },
|
||||
{ 43, 0x007c, 0x0000007c, 0x01, 0x00, 0x0000 },
|
||||
{ 43, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0000005a, 0x00, 0x00, 0x0000 },
|
||||
{ 44, 0x005a, 0x0000005a, 0x01, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0000005a, 0x02, 0x00, 0x0000 },
|
||||
{ 44, 0x005a, 0x0000005a, 0x03, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0400005a, 0x04, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0400005a, 0x05, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0400005a, 0x06, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0400005a, 0x07, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0800005a, 0x08, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0800005a, 0x09, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0800005a, 0x0a, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0800005a, 0x0b, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0c00005a, 0x0c, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0c00005a, 0x0d, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0c00005a, 0x0e, 0x00, 0x0000 },
|
||||
{ 44, 0x007a, 0x0c00005a, 0x0f, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x00000058, 0x00, 0x00, 0x0000 },
|
||||
{ 45, 0x0058, 0x00000058, 0x01, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x00000058, 0x02, 0x00, 0x0000 },
|
||||
{ 45, 0x0058, 0x00000058, 0x03, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x04000058, 0x04, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x04000058, 0x05, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x04000058, 0x06, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x04000058, 0x07, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x08000058, 0x08, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x08000058, 0x09, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x08000058, 0x0a, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x08000058, 0x0b, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x0c000058, 0x0c, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x0c000058, 0x0d, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x0c000058, 0x0e, 0x00, 0x0000 },
|
||||
{ 45, 0x0078, 0x0c000058, 0x0f, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x00000043, 0x00, 0x00, 0x0000 },
|
||||
{ 46, 0x0043, 0x00000043, 0x01, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x00000043, 0x02, 0x00, 0x0000 },
|
||||
{ 46, 0x0043, 0x00000043, 0x03, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x04000043, 0x04, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x04000043, 0x05, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x04000043, 0x06, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x04000043, 0x07, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x08000043, 0x08, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x08000043, 0x09, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x08000043, 0x0a, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x08000043, 0x0b, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x0c000043, 0x0c, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x0c000043, 0x0d, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x0c000043, 0x0e, 0x00, 0x0000 },
|
||||
{ 46, 0x0063, 0x0c000043, 0x0f, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x00000056, 0x00, 0x00, 0x0000 },
|
||||
{ 47, 0x0056, 0x00000056, 0x01, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x00000056, 0x02, 0x00, 0x0000 },
|
||||
{ 47, 0x0056, 0x00000056, 0x03, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x04000056, 0x04, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x04000056, 0x05, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x04000056, 0x06, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x04000056, 0x07, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x08000056, 0x08, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x08000056, 0x09, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x08000056, 0x0a, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x08000056, 0x0b, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x0c000056, 0x0c, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x0c000056, 0x0d, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x0c000056, 0x0e, 0x00, 0x0000 },
|
||||
{ 47, 0x0076, 0x0c000056, 0x0f, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x00000042, 0x00, 0x00, 0x0000 },
|
||||
{ 48, 0x0042, 0x00000042, 0x01, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x00000042, 0x02, 0x00, 0x0000 },
|
||||
{ 48, 0x0042, 0x00000042, 0x03, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x04000042, 0x04, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x04000042, 0x05, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x04000042, 0x06, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x04000042, 0x07, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x08000042, 0x08, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x08000042, 0x09, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x08000042, 0x0a, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x08000042, 0x0b, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x0c000042, 0x0c, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x0c000042, 0x0d, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x0c000042, 0x0e, 0x00, 0x0000 },
|
||||
{ 48, 0x0062, 0x0c000042, 0x0f, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0000004e, 0x00, 0x00, 0x0000 },
|
||||
{ 49, 0x004e, 0x0000004e, 0x01, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0000004e, 0x02, 0x00, 0x0000 },
|
||||
{ 49, 0x004e, 0x0000004e, 0x03, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0400004e, 0x04, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0400004e, 0x05, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0400004e, 0x06, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0400004e, 0x07, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0800004e, 0x08, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0800004e, 0x09, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0800004e, 0x0a, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0800004e, 0x0b, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0c00004e, 0x0c, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0c00004e, 0x0d, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0c00004e, 0x0e, 0x00, 0x0000 },
|
||||
{ 49, 0x006e, 0x0c00004e, 0x0f, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0000004d, 0x00, 0x00, 0x0000 },
|
||||
{ 50, 0x004d, 0x0000004d, 0x01, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0000004d, 0x02, 0x00, 0x0000 },
|
||||
{ 50, 0x004d, 0x0000004d, 0x03, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0400004d, 0x04, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0400004d, 0x05, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0400004d, 0x06, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0400004d, 0x07, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0800004d, 0x08, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0800004d, 0x09, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0800004d, 0x0a, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0800004d, 0x0b, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0c00004d, 0x0c, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0c00004d, 0x0d, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0c00004d, 0x0e, 0x00, 0x0000 },
|
||||
{ 50, 0x006d, 0x0c00004d, 0x0f, 0x00, 0x0000 },
|
||||
{ 51, 0x002c, 0x0000002c, 0x00, 0x00, 0x0000 },
|
||||
{ 51, 0x003c, 0x0000003c, 0x01, 0x00, 0x0000 },
|
||||
{ 51, 0x002c, 0x0100125b, 0x02, 0x01, 0x0000 },
|
||||
{ 52, 0x002e, 0x0000002e, 0x00, 0x00, 0x0000 },
|
||||
{ 52, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
|
||||
{ 52, 0xffff, 0x01001120, 0x02, 0x00, 0x0000 },
|
||||
{ 53, 0x002f, 0x0000002f, 0x00, 0x00, 0x0000 },
|
||||
{ 53, 0x003f, 0x0000003f, 0x01, 0x00, 0x0000 },
|
||||
{ 53, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
|
||||
{ 54, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
|
||||
{ 55, 0x002a, 0x2000002a, 0x00, 0x00, 0x0000 },
|
||||
{ 56, 0xffff, 0x01000023, 0x00, 0x04, 0x0008 },
|
||||
{ 57, 0x0020, 0x00000020, 0x00, 0x00, 0x0000 },
|
||||
{ 58, 0xffff, 0x01000024, 0x00, 0x00, 0x0000 },
|
||||
{ 59, 0xffff, 0x01000030, 0x00, 0x00, 0x0000 },
|
||||
{ 59, 0xffff, 0x0100003c, 0x01, 0x00, 0x0000 },
|
||||
{ 59, 0xffff, 0x01000048, 0x04, 0x00, 0x0000 },
|
||||
{ 59, 0xffff, 0x01000000, 0x0c, 0x08, 0x0100 },
|
||||
{ 60, 0xffff, 0x01000031, 0x00, 0x00, 0x0000 },
|
||||
{ 60, 0xffff, 0x0100003d, 0x01, 0x00, 0x0000 },
|
||||
{ 60, 0xffff, 0x01000049, 0x04, 0x00, 0x0000 },
|
||||
{ 60, 0xffff, 0x01000000, 0x0c, 0x08, 0x0101 },
|
||||
{ 61, 0xffff, 0x01000032, 0x00, 0x00, 0x0000 },
|
||||
{ 61, 0xffff, 0x0100003e, 0x01, 0x00, 0x0000 },
|
||||
{ 61, 0xffff, 0x0100004a, 0x04, 0x00, 0x0000 },
|
||||
{ 61, 0xffff, 0x01000000, 0x0c, 0x08, 0x0102 },
|
||||
{ 62, 0xffff, 0x01000033, 0x00, 0x00, 0x0000 },
|
||||
{ 62, 0xffff, 0x0100003f, 0x01, 0x00, 0x0000 },
|
||||
{ 62, 0xffff, 0x0100004b, 0x04, 0x00, 0x0000 },
|
||||
{ 62, 0xffff, 0x01000000, 0x0c, 0x08, 0x0103 },
|
||||
{ 63, 0xffff, 0x01000034, 0x00, 0x00, 0x0000 },
|
||||
{ 63, 0xffff, 0x01000040, 0x01, 0x00, 0x0000 },
|
||||
{ 63, 0xffff, 0x0100004c, 0x04, 0x00, 0x0000 },
|
||||
{ 63, 0xffff, 0x01000000, 0x0c, 0x08, 0x0104 },
|
||||
{ 64, 0xffff, 0x01000035, 0x00, 0x00, 0x0000 },
|
||||
{ 64, 0xffff, 0x01000041, 0x01, 0x00, 0x0000 },
|
||||
{ 64, 0xffff, 0x0100004d, 0x04, 0x00, 0x0000 },
|
||||
{ 64, 0xffff, 0x01000000, 0x0c, 0x08, 0x0105 },
|
||||
{ 65, 0xffff, 0x01000036, 0x00, 0x00, 0x0000 },
|
||||
{ 65, 0xffff, 0x01000042, 0x01, 0x00, 0x0000 },
|
||||
{ 65, 0xffff, 0x0100004e, 0x04, 0x00, 0x0000 },
|
||||
{ 65, 0xffff, 0x01000000, 0x0c, 0x08, 0x0106 },
|
||||
{ 66, 0xffff, 0x01000037, 0x00, 0x00, 0x0000 },
|
||||
{ 66, 0xffff, 0x01000043, 0x01, 0x00, 0x0000 },
|
||||
{ 66, 0xffff, 0x0100004f, 0x04, 0x00, 0x0000 },
|
||||
{ 66, 0xffff, 0x01000000, 0x0c, 0x08, 0x0107 },
|
||||
{ 67, 0xffff, 0x01000038, 0x00, 0x00, 0x0000 },
|
||||
{ 67, 0xffff, 0x01000044, 0x01, 0x00, 0x0000 },
|
||||
{ 67, 0xffff, 0x01000050, 0x04, 0x00, 0x0000 },
|
||||
{ 67, 0xffff, 0x01000000, 0x0c, 0x08, 0x0108 },
|
||||
{ 68, 0xffff, 0x01000039, 0x00, 0x00, 0x0000 },
|
||||
{ 68, 0xffff, 0x01000045, 0x01, 0x00, 0x0000 },
|
||||
{ 68, 0xffff, 0x01000051, 0x04, 0x00, 0x0000 },
|
||||
{ 68, 0xffff, 0x01000000, 0x0c, 0x08, 0x0109 },
|
||||
{ 69, 0xffff, 0x01000025, 0x00, 0x00, 0x0000 },
|
||||
{ 70, 0xffff, 0x01000026, 0x00, 0x00, 0x0000 },
|
||||
{ 70, 0xffff, 0x01000026, 0x08, 0x00, 0x0000 },
|
||||
{ 71, 0x0037, 0x20000037, 0x00, 0x00, 0x0000 },
|
||||
{ 72, 0x0038, 0x20000038, 0x00, 0x00, 0x0000 },
|
||||
{ 73, 0x0039, 0x20000039, 0x00, 0x00, 0x0000 },
|
||||
{ 74, 0x002d, 0x2000002d, 0x00, 0x00, 0x0000 },
|
||||
{ 75, 0x0034, 0x20000034, 0x00, 0x00, 0x0000 },
|
||||
{ 76, 0x0035, 0x20000035, 0x00, 0x00, 0x0000 },
|
||||
{ 77, 0x0036, 0x20000036, 0x00, 0x00, 0x0000 },
|
||||
{ 78, 0x002b, 0x2000002b, 0x00, 0x00, 0x0000 },
|
||||
{ 79, 0x0031, 0x20000031, 0x00, 0x00, 0x0000 },
|
||||
{ 80, 0x0032, 0x20000032, 0x00, 0x00, 0x0000 },
|
||||
{ 81, 0x0033, 0x20000033, 0x00, 0x00, 0x0000 },
|
||||
{ 82, 0x0030, 0x20000030, 0x00, 0x00, 0x0000 },
|
||||
{ 83, 0x002e, 0x2000002e, 0x00, 0x00, 0x0000 },
|
||||
{ 83, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
|
||||
{ 83, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
|
||||
{ 86, 0x003c, 0x0000003c, 0x00, 0x00, 0x0000 },
|
||||
{ 86, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
|
||||
{ 86, 0x007c, 0x0000007c, 0x02, 0x00, 0x0000 },
|
||||
{ 87, 0xffff, 0x0100003a, 0x00, 0x00, 0x0000 },
|
||||
{ 87, 0xffff, 0x01000046, 0x01, 0x00, 0x0000 },
|
||||
{ 87, 0xffff, 0x01000052, 0x04, 0x00, 0x0000 },
|
||||
{ 87, 0xffff, 0x01000000, 0x0c, 0x08, 0x010a },
|
||||
{ 88, 0xffff, 0x0100003b, 0x00, 0x00, 0x0000 },
|
||||
{ 88, 0xffff, 0x01000047, 0x01, 0x00, 0x0000 },
|
||||
{ 88, 0xffff, 0x01000000, 0x0c, 0x08, 0x010b },
|
||||
{ 96, 0xffff, 0x21000005, 0x00, 0x00, 0x0000 },
|
||||
{ 97, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
|
||||
{ 98, 0x002f, 0x2000002f, 0x00, 0x00, 0x0000 },
|
||||
{ 99, 0x005c, 0x0400005c, 0x00, 0x00, 0x0000 },
|
||||
{ 100, 0xffff, 0x01001103, 0x00, 0x04, 0x0002 },
|
||||
{ 102, 0xffff, 0x01000010, 0x00, 0x00, 0x0000 },
|
||||
{ 103, 0xffff, 0x01000013, 0x00, 0x00, 0x0000 },
|
||||
{ 104, 0xffff, 0x01000016, 0x00, 0x00, 0x0000 },
|
||||
{ 105, 0xffff, 0x01000012, 0x00, 0x00, 0x0000 },
|
||||
{ 105, 0xffff, 0x01000000, 0x0c, 0x08, 0x0180 },
|
||||
{ 106, 0xffff, 0x01000014, 0x00, 0x00, 0x0000 },
|
||||
{ 106, 0xffff, 0x01000000, 0x0c, 0x08, 0x0181 },
|
||||
{ 107, 0xffff, 0x01000011, 0x00, 0x00, 0x0000 },
|
||||
{ 108, 0xffff, 0x01000015, 0x00, 0x00, 0x0000 },
|
||||
{ 109, 0xffff, 0x01000017, 0x00, 0x00, 0x0000 },
|
||||
{ 110, 0xffff, 0x01000006, 0x00, 0x00, 0x0000 },
|
||||
{ 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 },
|
||||
{ 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
|
||||
{ 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
|
||||
{ 113, 0xffff, 0x01000071, 0x00, 0x00, 0x0000 },
|
||||
{ 114, 0xffff, 0x01000070, 0x00, 0x00, 0x0000 },
|
||||
{ 115, 0xffff, 0x01000072, 0x00, 0x00, 0x0000 },
|
||||
{ 116, 0xffff, 0x0100010b, 0x00, 0x00, 0x0000 },
|
||||
{ 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 },
|
||||
{ 138, 0xffff, 0x01000058, 0x00, 0x00, 0x0000 },
|
||||
{ 139, 0xffff, 0x01000055, 0x00, 0x00, 0x0000 },
|
||||
{ 152, 0xffff, 0x010000ba, 0x00, 0x00, 0x0000 },
|
||||
|
||||
};
|
||||
|
||||
const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = {
|
||||
{ 0x0060, 0x0041, 0x00c0 },
|
||||
{ 0x0060, 0x0061, 0x00e0 },
|
||||
{ 0x0027, 0x0041, 0x00c1 },
|
||||
{ 0x0027, 0x0061, 0x00e1 },
|
||||
{ 0x005e, 0x0041, 0x00c2 },
|
||||
{ 0x005e, 0x0061, 0x00e2 },
|
||||
{ 0x007e, 0x0041, 0x00c3 },
|
||||
{ 0x007e, 0x0061, 0x00e3 },
|
||||
{ 0x0022, 0x0041, 0x00c4 },
|
||||
{ 0x0022, 0x0061, 0x00e4 },
|
||||
{ 0x002d, 0x0061, 0x00aa },
|
||||
{ 0x002d, 0x0041, 0x00aa },
|
||||
{ 0x004f, 0x0041, 0x00c5 },
|
||||
{ 0x006f, 0x0061, 0x00e5 },
|
||||
{ 0x0030, 0x0041, 0x00c5 },
|
||||
{ 0x0030, 0x0061, 0x00e5 },
|
||||
{ 0x0041, 0x0041, 0x00c5 },
|
||||
{ 0x0061, 0x0061, 0x00e5 },
|
||||
{ 0x00b0, 0x0041, 0x00c5 },
|
||||
{ 0x00b0, 0x0061, 0x00e5 },
|
||||
{ 0x0041, 0x0045, 0x00c6 },
|
||||
{ 0x0061, 0x0065, 0x00e6 },
|
||||
{ 0x002c, 0x0043, 0x00c7 },
|
||||
{ 0x002c, 0x0063, 0x00e7 },
|
||||
{ 0x005e, 0x0043, 0x00c7 },
|
||||
{ 0x005e, 0x0063, 0x00e7 },
|
||||
{ 0x0060, 0x0045, 0x00c8 },
|
||||
{ 0x0060, 0x0065, 0x00e8 },
|
||||
{ 0x0027, 0x0045, 0x00c9 },
|
||||
{ 0x0027, 0x0065, 0x00e9 },
|
||||
{ 0x005e, 0x0045, 0x00ca },
|
||||
{ 0x005e, 0x0065, 0x00ea },
|
||||
{ 0x0022, 0x0045, 0x00cb },
|
||||
{ 0x0022, 0x0065, 0x00eb },
|
||||
{ 0x0060, 0x0049, 0x00cc },
|
||||
{ 0x0060, 0x0069, 0x00ec },
|
||||
{ 0x0027, 0x0049, 0x00cd },
|
||||
{ 0x0027, 0x0069, 0x00ed },
|
||||
{ 0x005e, 0x0049, 0x00ce },
|
||||
{ 0x005e, 0x0069, 0x00ee },
|
||||
{ 0x0022, 0x0049, 0x00cf },
|
||||
{ 0x0022, 0x0069, 0x00ef },
|
||||
{ 0x002d, 0x0044, 0x00d0 },
|
||||
{ 0x002d, 0x0064, 0x00f0 },
|
||||
{ 0x005e, 0x0044, 0x00d0 },
|
||||
{ 0x005e, 0x0064, 0x00f0 },
|
||||
{ 0x007e, 0x004e, 0x00d1 },
|
||||
{ 0x007e, 0x006e, 0x00f1 },
|
||||
{ 0x005e, 0x004e, 0x00d1 },
|
||||
{ 0x005e, 0x006e, 0x00f1 },
|
||||
{ 0x0060, 0x004f, 0x00d2 },
|
||||
{ 0x0060, 0x006f, 0x00f2 },
|
||||
{ 0x0027, 0x004f, 0x00d3 },
|
||||
{ 0x0027, 0x006f, 0x00f3 },
|
||||
{ 0x005e, 0x004f, 0x00d4 },
|
||||
{ 0x005e, 0x006f, 0x00f4 },
|
||||
{ 0x007e, 0x004f, 0x00d5 },
|
||||
{ 0x007e, 0x006f, 0x00f5 },
|
||||
{ 0x0022, 0x004f, 0x00d6 },
|
||||
{ 0x0022, 0x006f, 0x00f6 },
|
||||
{ 0x002f, 0x004f, 0x00d8 },
|
||||
{ 0x002f, 0x006f, 0x00f8 },
|
||||
{ 0x002d, 0x006f, 0x00ba },
|
||||
{ 0x002d, 0x004f, 0x00ba },
|
||||
{ 0x0060, 0x0055, 0x00d9 },
|
||||
{ 0x0060, 0x0075, 0x00f9 },
|
||||
{ 0x0027, 0x0055, 0x00da },
|
||||
{ 0x0027, 0x0075, 0x00fa },
|
||||
{ 0x005e, 0x0055, 0x00db },
|
||||
{ 0x005e, 0x0075, 0x00fb },
|
||||
{ 0x0022, 0x0055, 0x00dc },
|
||||
{ 0x0022, 0x0075, 0x00fc },
|
||||
{ 0x0027, 0x0059, 0x00dd },
|
||||
{ 0x0027, 0x0079, 0x00fd },
|
||||
{ 0x0054, 0x0048, 0x00de },
|
||||
{ 0x0074, 0x0068, 0x00fe },
|
||||
{ 0x0073, 0x0073, 0x00df },
|
||||
{ 0x0022, 0x0079, 0x00ff },
|
||||
{ 0x0073, 0x007a, 0x00df },
|
||||
{ 0x006e, 0x006e, 0x00f1 },
|
||||
{ 0x006e, 0x0068, 0x00f1 },
|
||||
{ 0x004e, 0x0059, 0x00d1 },
|
||||
{ 0x004e, 0x004e, 0x00d1 },
|
||||
{ 0x004e, 0x0048, 0x00d1 },
|
||||
{ 0x004e, 0x0079, 0x00d1 },
|
||||
{ 0x004e, 0x006e, 0x00d1 },
|
||||
{ 0x004e, 0x0068, 0x00d1 },
|
||||
{ 0x002d, 0x004c, 0x00a3 },
|
||||
{ 0x003c, 0x003c, 0x00ab },
|
||||
{ 0x003e, 0x003e, 0x00bb },
|
||||
{ 0x003f, 0x003f, 0x00bf },
|
||||
{ 0x005e, 0x003f, 0x00bf },
|
||||
{ 0x0021, 0x0021, 0x00a1 },
|
||||
{ 0x005e, 0x0021, 0x00a1 },
|
||||
{ 0x005e, 0x0031, 0x00b9 },
|
||||
{ 0x005e, 0x0032, 0x00b2 },
|
||||
{ 0x005e, 0x0033, 0x00b3 },
|
||||
{ 0x002b, 0x002d, 0x00b1 },
|
||||
{ 0x0063, 0x003d, 0x00a2 },
|
||||
{ 0x0063, 0x002f, 0x00a2 },
|
||||
{ 0x002f, 0x0063, 0x00a2 },
|
||||
{ 0x002d, 0x0063, 0x00a2 },
|
||||
{ 0x002d, 0x0043, 0x00a2 },
|
||||
{ 0x004c, 0x003d, 0x00a3 },
|
||||
{ 0x002d, 0x004c, 0x00a3 },
|
||||
{ 0x002d, 0x006c, 0x00a3 },
|
||||
{ 0x005e, 0x002a, 0x00d7 },
|
||||
{ 0x005e, 0x0078, 0x00d7 },
|
||||
{ 0x0078, 0x0078, 0x00d7 },
|
||||
{ 0x005e, 0x002e, 0x00b7 },
|
||||
{ 0x002e, 0x002e, 0x00b7 },
|
||||
{ 0x005e, 0x002f, 0x00f7 },
|
||||
{ 0x005e, 0x003a, 0x00f7 },
|
||||
{ 0x002d, 0x003a, 0x00f7 },
|
||||
{ 0x003a, 0x002d, 0x00f7 },
|
||||
{ 0x0059, 0x003d, 0x00a5 },
|
||||
{ 0x002d, 0x0059, 0x00a5 },
|
||||
{ 0x002d, 0x006c, 0x00a5 },
|
||||
{ 0x0028, 0x0063, 0x00a9 },
|
||||
{ 0x0022, 0x0063, 0x00a9 },
|
||||
{ 0x002d, 0x0061, 0x00aa },
|
||||
{ 0x002d, 0x0041, 0x00aa },
|
||||
{ 0x002d, 0x006f, 0x00ba },
|
||||
{ 0x002d, 0x004f, 0x00ba },
|
||||
{ 0x0028, 0x0072, 0x00ae },
|
||||
{ 0x0022, 0x0072, 0x00ae },
|
||||
{ 0x006d, 0x0075, 0x00b5 },
|
||||
{ 0x0031, 0x0034, 0x0152 },
|
||||
{ 0x0031, 0x0032, 0x0153 },
|
||||
{ 0x0033, 0x0034, 0x0178 },
|
||||
{ 0x0065, 0x003d, 0x20ac },
|
||||
{ 0x002d, 0x0065, 0x20ac },
|
||||
{ 0x002d, 0x0045, 0x20ac },
|
||||
{ 0x0076, 0x0053, 0x0160 },
|
||||
{ 0x005e, 0x0053, 0x0160 },
|
||||
{ 0x0076, 0x0073, 0x0161 },
|
||||
{ 0x005e, 0x0073, 0x0161 },
|
||||
{ 0x0076, 0x005a, 0x017d },
|
||||
{ 0x005e, 0x005a, 0x017d },
|
||||
{ 0x0076, 0x007a, 0x017e },
|
||||
{ 0x005e, 0x007a, 0x017e },
|
||||
{ 0x004f, 0x0045, 0x0152 },
|
||||
{ 0x004f, 0x0065, 0x0152 },
|
||||
{ 0x006f, 0x0065, 0x0153 },
|
||||
{ 0x0022, 0x0059, 0x0178 },
|
||||
{ 0x0069, 0x006a, 0x00ff },
|
||||
{ 0x0049, 0x004a, 0x0178 },
|
||||
};
|
||||
|
||||
#endif
|
@ -1,693 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbd_qws.h"
|
||||
#include "qkbd_qws_p.h"
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
#include <QStringList>
|
||||
|
||||
#ifdef Q_WS_QWS
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qscreen_qws.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_QPA
|
||||
#include <QWindowSystemInterface>
|
||||
#include <QKeyEvent>
|
||||
#endif
|
||||
|
||||
#include "qtimer.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
//#define QT_DEBUG_KEYMAP
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWSKbPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSKbPrivate(QWSKeyboardHandler *h, const QString &device)
|
||||
: m_handler(h), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),
|
||||
m_no_zap(false), m_do_compose(false),
|
||||
m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
|
||||
{
|
||||
m_ar_timer = new QTimer(this);
|
||||
m_ar_timer->setSingleShot(true);
|
||||
connect(m_ar_timer, SIGNAL(timeout()), SLOT(autoRepeat()));
|
||||
m_ar_delay = 400;
|
||||
m_ar_period = 80;
|
||||
|
||||
memset(m_locks, 0, sizeof(m_locks));
|
||||
|
||||
QString keymap;
|
||||
QStringList args = device.split(QLatin1Char(':'));
|
||||
foreach (const QString &arg, args) {
|
||||
if (arg.startsWith(QLatin1String("keymap=")))
|
||||
keymap = arg.mid(7);
|
||||
else if (arg == QLatin1String("disable-zap"))
|
||||
m_no_zap = true;
|
||||
else if (arg == QLatin1String("enable-compose"))
|
||||
m_do_compose = true;
|
||||
else if (arg.startsWith(QLatin1String("repeat-delay=")))
|
||||
m_ar_delay = arg.mid(13).toInt();
|
||||
else if (arg.startsWith(QLatin1String("repeat-rate=")))
|
||||
m_ar_period = arg.mid(12).toInt();
|
||||
}
|
||||
|
||||
if (keymap.isEmpty() || !loadKeymap(keymap))
|
||||
unloadKeymap();
|
||||
}
|
||||
|
||||
~QWSKbPrivate()
|
||||
{
|
||||
unloadKeymap();
|
||||
}
|
||||
|
||||
void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod)
|
||||
{
|
||||
m_ar_unicode = uni;
|
||||
m_ar_keycode = code;
|
||||
m_ar_modifier = mod;
|
||||
m_ar_timer->start(m_ar_delay);
|
||||
}
|
||||
|
||||
void endAutoRepeat()
|
||||
{
|
||||
m_ar_timer->stop();
|
||||
}
|
||||
|
||||
static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
|
||||
{
|
||||
Qt::KeyboardModifiers qtmod = Qt::NoModifier;
|
||||
|
||||
if (mod & (QWSKeyboard::ModShift | QWSKeyboard::ModShiftL | QWSKeyboard::ModShiftR))
|
||||
qtmod |= Qt::ShiftModifier;
|
||||
if (mod & (QWSKeyboard::ModControl | QWSKeyboard::ModCtrlL | QWSKeyboard::ModCtrlR))
|
||||
qtmod |= Qt::ControlModifier;
|
||||
if (mod & QWSKeyboard::ModAlt)
|
||||
qtmod |= Qt::AltModifier;
|
||||
|
||||
return qtmod;
|
||||
}
|
||||
|
||||
void unloadKeymap();
|
||||
bool loadKeymap(const QString &file);
|
||||
|
||||
private slots:
|
||||
void autoRepeat()
|
||||
{
|
||||
m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, false, true);
|
||||
m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, true, true);
|
||||
m_ar_timer->start(m_ar_period);
|
||||
}
|
||||
|
||||
private:
|
||||
QWSKeyboardHandler *m_handler;
|
||||
|
||||
// auto repeat simulation
|
||||
int m_ar_unicode;
|
||||
int m_ar_keycode;
|
||||
Qt::KeyboardModifiers m_ar_modifier;
|
||||
int m_ar_delay;
|
||||
int m_ar_period;
|
||||
QTimer *m_ar_timer;
|
||||
|
||||
// keymap handling
|
||||
quint8 m_modifiers;
|
||||
quint8 m_locks[3];
|
||||
int m_composing;
|
||||
quint16 m_dead_unicode;
|
||||
|
||||
bool m_no_zap;
|
||||
bool m_do_compose;
|
||||
|
||||
const QWSKeyboard::Mapping *m_keymap;
|
||||
int m_keymap_size;
|
||||
const QWSKeyboard::Composing *m_keycompose;
|
||||
int m_keycompose_size;
|
||||
|
||||
static const QWSKeyboard::Mapping s_keymap_default[];
|
||||
static const QWSKeyboard::Composing s_keycompose_default[];
|
||||
|
||||
friend class QWSKeyboardHandler;
|
||||
};
|
||||
|
||||
// simple builtin US keymap
|
||||
#include "qkbd_defaultmap_qws_p.h"
|
||||
|
||||
// the unloadKeymap() function needs to be AFTER the defaultmap include,
|
||||
// since the sizeof(s_keymap_default) wouldn't work otherwise.
|
||||
|
||||
void QWSKbPrivate::unloadKeymap()
|
||||
{
|
||||
if (m_keymap && m_keymap != s_keymap_default)
|
||||
delete [] m_keymap;
|
||||
if (m_keycompose && m_keycompose != s_keycompose_default)
|
||||
delete [] m_keycompose;
|
||||
|
||||
m_keymap = s_keymap_default;
|
||||
m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);
|
||||
m_keycompose = s_keycompose_default;
|
||||
m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]);
|
||||
|
||||
// reset state, so we could switch keymaps at runtime
|
||||
m_modifiers = 0;
|
||||
memset(m_locks, 0, sizeof(m_locks));
|
||||
m_composing = 0;
|
||||
m_dead_unicode = 0xffff;
|
||||
}
|
||||
|
||||
bool QWSKbPrivate::loadKeymap(const QString &file)
|
||||
{
|
||||
QFile f(file);
|
||||
|
||||
if (!f.open(QIODevice::ReadOnly)) {
|
||||
qWarning("Could not open keymap file '%s'", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
// .qmap files have a very simple structure:
|
||||
// quint32 magic (QWSKeyboard::FileMagic)
|
||||
// quint32 version (1)
|
||||
// quint32 keymap_size (# of struct QWSKeyboard::Mappings)
|
||||
// quint32 keycompose_size (# of struct QWSKeyboard::Composings)
|
||||
// all QWSKeyboard::Mappings via QDataStream::operator(<<|>>)
|
||||
// all QWSKeyboard::Composings via QDataStream::operator(<<|>>)
|
||||
|
||||
quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size;
|
||||
|
||||
QDataStream ds(&f);
|
||||
|
||||
ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
|
||||
|
||||
if (ds.status() != QDataStream::Ok || qmap_magic != QWSKeyboard::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
|
||||
qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
QWSKeyboard::Mapping *qmap_keymap = new QWSKeyboard::Mapping[qmap_keymap_size];
|
||||
QWSKeyboard::Composing *qmap_keycompose = qmap_keycompose_size ? new QWSKeyboard::Composing[qmap_keycompose_size] : 0;
|
||||
|
||||
for (quint32 i = 0; i < qmap_keymap_size; ++i)
|
||||
ds >> qmap_keymap[i];
|
||||
for (quint32 i = 0; i < qmap_keycompose_size; ++i)
|
||||
ds >> qmap_keycompose[i];
|
||||
|
||||
if (ds.status() != QDataStream::Ok) {
|
||||
delete [] qmap_keymap;
|
||||
delete [] qmap_keycompose;
|
||||
|
||||
qWarning("Keymap file '%s' can not be loaded.", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
// unload currently active and clear state
|
||||
unloadKeymap();
|
||||
|
||||
m_keymap = qmap_keymap;
|
||||
m_keymap_size = qmap_keymap_size;
|
||||
m_keycompose = qmap_keycompose;
|
||||
m_keycompose_size = qmap_keycompose_size;
|
||||
|
||||
m_do_compose = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QWSKeyboardHandler
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSKeyboardHandler class is a base class for keyboard
|
||||
drivers in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
|
||||
protocols, see the \l{Qt for Embedded Linux Character Input}{character
|
||||
input} documentation for details. Custom keyboard drivers can be
|
||||
implemented by subclassing the QWSKeyboardHandler class and
|
||||
creating a keyboard driver plugin (derived from
|
||||
QKbdDriverPlugin). The default implementation of the
|
||||
QKbdDriverFactory class will automatically detect the plugin, and
|
||||
load the driver into the server application at run-time using Qt's
|
||||
\l{How to Create Qt Plugins}{plugin system}.
|
||||
|
||||
The keyboard driver receives keyboard events from the system
|
||||
device and encapsulates each event with an instance of the
|
||||
QWSEvent class which it then passes to the server application (the
|
||||
server is responsible for propagating the event to the appropriate
|
||||
client). To receive keyboard events, a QWSKeyboardHandler object
|
||||
will usually create a QSocketNotifier object for the given
|
||||
device. The QSocketNotifier class provides support for monitoring
|
||||
activity on a file descriptor. When the socket notifier receives
|
||||
data, it will call the keyboard driver's processKeyEvent()
|
||||
function to send the event to the \l{Qt for Embedded Linux} server
|
||||
application for relaying to clients.
|
||||
|
||||
|
||||
QWSKeyboardHandler also provides functions to control
|
||||
auto-repetion of key sequences, beginAutoRepeat() and
|
||||
endAutoRepeat(), and the transformDirKey() function enabling
|
||||
transformation of arrow keys according to the display orientation.
|
||||
|
||||
\sa QKbdDriverPlugin, QKbdDriverFactory, {Qt for Embedded Linux Character Input}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a keyboard driver. The \a device argument is passed by the
|
||||
QWS_KEYBOARD environment variable.
|
||||
|
||||
Call the QWSServer::setKeyboardHandler() function to make the
|
||||
newly created keyboard driver, the primary driver. Note that the
|
||||
primary driver is controlled by the system, i.e., the system will
|
||||
delete it upon exit.
|
||||
*/
|
||||
QWSKeyboardHandler::QWSKeyboardHandler(const QString &device)
|
||||
{
|
||||
d = new QWSKbPrivate(this, device);
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
QWSKeyboardHandler::QWSKeyboardHandler()
|
||||
{
|
||||
d = new QWSKbPrivate(this, QString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Destroys this keyboard driver.
|
||||
|
||||
Do not call this function if this driver is the primary keyboard
|
||||
handler, i.e., if QWSServer::setKeyboardHandler() function has
|
||||
been called passing this driver as argument. The primary keyboard
|
||||
driver is deleted by the system.
|
||||
*/
|
||||
QWSKeyboardHandler::~QWSKeyboardHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Sends a key event to the \l{Qt for Embedded Linux} server application.
|
||||
|
||||
The key event is identified by its \a unicode value and the \a
|
||||
keycode, \a modifiers, \a isPress and \a autoRepeat parameters.
|
||||
|
||||
The \a keycode parameter is the Qt keycode value as defined by the
|
||||
Qt::Key enum. The \a modifiers is an OR combination of
|
||||
Qt::KeyboardModifier values, indicating whether \gui
|
||||
Shift/Alt/Ctrl keys are pressed. The \a isPress parameter is true
|
||||
if the event is a key press event and \a autoRepeat is true if the
|
||||
event is caused by an auto-repeat mechanism and not an actual key
|
||||
press.
|
||||
|
||||
Note that this function does not handle key mapping. Please use
|
||||
processKeycode() if you need that functionality.
|
||||
|
||||
\sa processKeycode(), beginAutoRepeat(), endAutoRepeat(), transformDirKey()
|
||||
*/
|
||||
void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
|
||||
bool isPress, bool autoRepeat)
|
||||
{
|
||||
#if defined(Q_WS_QWS)
|
||||
qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat);
|
||||
#elif defined(Q_WS_QPA)
|
||||
QEvent::Type type = isPress ? QEvent::KeyPress : QEvent::KeyRelease;
|
||||
QString str;
|
||||
if (unicode != 0xffff)
|
||||
str = QString(unicode);
|
||||
QWindowSystemInterface::handleKeyEvent(0, type, keycode, modifiers, str);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int QWSKeyboardHandler::transformDirKey(int keycode)
|
||||
|
||||
Transforms the arrow key specified by the given \a keycode, to the
|
||||
orientation of the display and returns the transformed keycode.
|
||||
|
||||
The \a keycode is a Qt::Key value. The values identifying arrow
|
||||
keys are:
|
||||
|
||||
\list
|
||||
\o Qt::Key_Left
|
||||
\o Qt::Key_Up
|
||||
\o Qt::Key_Right
|
||||
\o Qt::Key_Down
|
||||
\endlist
|
||||
|
||||
\sa processKeyEvent()
|
||||
*/
|
||||
int QWSKeyboardHandler::transformDirKey(int key)
|
||||
{
|
||||
#ifdef Q_WS_QWS
|
||||
static int dir_keyrot = -1;
|
||||
if (dir_keyrot < 0) {
|
||||
// get the rotation
|
||||
switch (qgetenv("QWS_CURSOR_ROTATION").toInt()) {
|
||||
case 90: dir_keyrot = 1; break;
|
||||
case 180: dir_keyrot = 2; break;
|
||||
case 270: dir_keyrot = 3; break;
|
||||
default: dir_keyrot = 0; break;
|
||||
}
|
||||
}
|
||||
int xf = qt_screen->transformOrientation() + dir_keyrot;
|
||||
return (key-Qt::Key_Left+xf)%4+Qt::Key_Left;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QWSKeyboardHandler::beginAutoRepeat(int unicode, int keycode, Qt::KeyboardModifiers modifier)
|
||||
|
||||
Begins auto-repeating the specified key press; after a short delay
|
||||
the key press is sent periodically until the endAutoRepeat()
|
||||
function is called.
|
||||
|
||||
The key press is specified by its \a unicode, \a keycode and \a
|
||||
modifier state.
|
||||
|
||||
\sa endAutoRepeat(), processKeyEvent()
|
||||
*/
|
||||
void QWSKeyboardHandler::beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod)
|
||||
{
|
||||
d->beginAutoRepeat(uni, code, mod);
|
||||
}
|
||||
|
||||
/*!
|
||||
Stops auto-repeating a key press.
|
||||
|
||||
\sa beginAutoRepeat(), processKeyEvent()
|
||||
*/
|
||||
void QWSKeyboardHandler::endAutoRepeat()
|
||||
{
|
||||
d->endAutoRepeat();
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QWSKeyboardHandler::KeycodeAction
|
||||
|
||||
This enum describes the various special actions that actual
|
||||
QWSKeyboardHandler implementations have to take care of.
|
||||
|
||||
\value None No further action required.
|
||||
|
||||
\value CapsLockOn Set the state of the Caps lock LED to on.
|
||||
\value CapsLockOff Set the state of the Caps lock LED to off.
|
||||
\value NumLockOn Set the state of the Num lock LED to on.
|
||||
\value NumLockOff Set the state of the Num lock LED to off.
|
||||
\value ScrollLockOn Set the state of the Scroll lock LED to on.
|
||||
\value ScrollLockOff Set the state of the Scroll lock LED to off.
|
||||
|
||||
\value PreviousConsole Switch to the previous virtual console (by
|
||||
default Ctrl+Alt+Left on Linux).
|
||||
\value NextConsole Switch to the next virtual console (by default
|
||||
Ctrl+Alt+Right on Linux).
|
||||
\value SwitchConsoleFirst Switch to the first virtual console (0).
|
||||
\value SwitchConsoleLast Switch to the last virtual console (255).
|
||||
\value SwitchConsoleMask If the KeyAction value is between SwitchConsoleFirst
|
||||
and SwitchConsoleLast, you can use this mask to get
|
||||
the specific virtual console number to switch to.
|
||||
|
||||
\value Reboot Reboot the machine - this is ignored in both the TTY and
|
||||
LinuxInput handlers though (by default Ctrl+Alt+Del on Linux).
|
||||
|
||||
\sa processKeycode()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool isPress, bool autoRepeat)
|
||||
|
||||
\since 4.6
|
||||
|
||||
Maps \a keycode according to a keymap and sends that key event to the
|
||||
\l{Qt for Embedded Linux} server application.
|
||||
|
||||
Please see the \l{Qt for Embedded Linux Character Input} and the \l
|
||||
{kmap2qmap} documentations for a description on how to create and use
|
||||
keymap files.
|
||||
|
||||
The key event is identified by its \a keycode value and the \a isPress
|
||||
and \a autoRepeat parameters.
|
||||
|
||||
The \a keycode parameter is \bold NOT the Qt keycode value as defined by
|
||||
the Qt::Key enum. This functions expects a standard Linux 16 bit kernel
|
||||
keycode as it is used in the Linux Input Event sub-system. This
|
||||
\a keycode is transformed to a Qt::Key code by using either a
|
||||
compiled-in US keyboard layout or by dynamically loading a keymap at
|
||||
startup which can be specified via the QWS_KEYBOARD environment
|
||||
variable.
|
||||
|
||||
The \a isPress parameter is true if the event is a key press event and
|
||||
\a autoRepeat is true if the event is caused by an auto-repeat mechanism
|
||||
and not an actual key press.
|
||||
|
||||
The return value indicates if the actual QWSKeyboardHandler
|
||||
implementation needs to take care of a special action, like console
|
||||
switching or LED handling.
|
||||
|
||||
If standard Linux console keymaps are used, \a keycode must be one of the
|
||||
standardized values defined in \c /usr/include/linux/input.h
|
||||
|
||||
\sa processKeyEvent(), KeycodeAction
|
||||
*/
|
||||
|
||||
QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)
|
||||
{
|
||||
KeycodeAction result = None;
|
||||
bool first_press = pressed && !autorepeat;
|
||||
|
||||
const QWSKeyboard::Mapping *map_plain = 0;
|
||||
const QWSKeyboard::Mapping *map_withmod = 0;
|
||||
|
||||
// get a specific and plain mapping for the keycode and the current modifiers
|
||||
for (int i = 0; i < d->m_keymap_size && !(map_plain && map_withmod); ++i) {
|
||||
const QWSKeyboard::Mapping *m = d->m_keymap + i;
|
||||
if (m->keycode == keycode) {
|
||||
if (m->modifiers == 0)
|
||||
map_plain = m;
|
||||
|
||||
quint8 testmods = d->m_modifiers;
|
||||
if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter))
|
||||
testmods ^= QWSKeyboard::ModShift;
|
||||
if (m->modifiers == testmods)
|
||||
map_withmod = m;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG_KEYMAP
|
||||
qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \
|
||||
keycode, d->m_modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \
|
||||
map_plain ? map_plain - d->m_keymap : -1, \
|
||||
map_withmod ? map_withmod - d->m_keymap : -1, \
|
||||
d->m_keymap_size);
|
||||
#endif
|
||||
|
||||
const QWSKeyboard::Mapping *it = map_withmod ? map_withmod : map_plain;
|
||||
|
||||
if (!it) {
|
||||
#ifdef QT_DEBUG_KEYMAP
|
||||
// we couldn't even find a plain mapping
|
||||
qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, d->m_modifiers);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
bool skip = false;
|
||||
quint16 unicode = it->unicode;
|
||||
quint32 qtcode = it->qtcode;
|
||||
|
||||
if ((it->flags & QWSKeyboard::IsModifier) && it->special) {
|
||||
// this is a modifier, i.e. Shift, Alt, ...
|
||||
if (pressed)
|
||||
d->m_modifiers |= quint8(it->special);
|
||||
else
|
||||
d->m_modifiers &= ~quint8(it->special);
|
||||
} else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) {
|
||||
// (Caps|Num|Scroll)Lock
|
||||
if (first_press) {
|
||||
quint8 &lock = d->m_locks[qtcode - Qt::Key_CapsLock];
|
||||
lock ^= 1;
|
||||
|
||||
switch (qtcode) {
|
||||
case Qt::Key_CapsLock : result = lock ? CapsLockOn : CapsLockOff; break;
|
||||
case Qt::Key_NumLock : result = lock ? NumLockOn : NumLockOff; break;
|
||||
case Qt::Key_ScrollLock: result = lock ? ScrollLockOn : ScrollLockOff; break;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
} else if ((it->flags & QWSKeyboard::IsSystem) && it->special && first_press) {
|
||||
switch (it->special) {
|
||||
case QWSKeyboard::SystemReboot:
|
||||
result = Reboot;
|
||||
break;
|
||||
|
||||
case QWSKeyboard::SystemZap:
|
||||
if (!d->m_no_zap)
|
||||
qApp->quit();
|
||||
break;
|
||||
|
||||
case QWSKeyboard::SystemConsolePrevious:
|
||||
result = PreviousConsole;
|
||||
break;
|
||||
|
||||
case QWSKeyboard::SystemConsoleNext:
|
||||
result = NextConsole;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (it->special >= QWSKeyboard::SystemConsoleFirst &&
|
||||
it->special <= QWSKeyboard::SystemConsoleLast) {
|
||||
result = KeycodeAction(SwitchConsoleFirst + ((it->special & QWSKeyboard::SystemConsoleMask) & SwitchConsoleMask));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
skip = true; // no need to tell QWS about it
|
||||
} else if ((qtcode == Qt::Key_Multi_key) && d->m_do_compose) {
|
||||
// the Compose key was pressed
|
||||
if (first_press)
|
||||
d->m_composing = 2;
|
||||
skip = true;
|
||||
} else if ((it->flags & QWSKeyboard::IsDead) && d->m_do_compose) {
|
||||
// a Dead key was pressed
|
||||
if (first_press && d->m_composing == 1 && d->m_dead_unicode == unicode) { // twice
|
||||
d->m_composing = 0;
|
||||
qtcode = Qt::Key_unknown; // otherwise it would be Qt::Key_Dead...
|
||||
} else if (first_press && unicode != 0xffff) {
|
||||
d->m_dead_unicode = unicode;
|
||||
d->m_composing = 1;
|
||||
skip = true;
|
||||
} else {
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip) {
|
||||
// a normal key was pressed
|
||||
const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier;
|
||||
|
||||
// we couldn't find a specific mapping for the current modifiers,
|
||||
// or that mapping didn't have special modifiers:
|
||||
// so just report the plain mapping with additional modifiers.
|
||||
if ((it == map_plain && it != map_withmod) ||
|
||||
(map_withmod && !(map_withmod->qtcode & modmask))) {
|
||||
qtcode |= QWSKbPrivate::toQtModifiers(d->m_modifiers);
|
||||
}
|
||||
|
||||
if (d->m_composing == 2 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
|
||||
// the last key press was the Compose key
|
||||
if (unicode != 0xffff) {
|
||||
int idx = 0;
|
||||
// check if this code is in the compose table at all
|
||||
for ( ; idx < d->m_keycompose_size; ++idx) {
|
||||
if (d->m_keycompose[idx].first == unicode)
|
||||
break;
|
||||
}
|
||||
if (idx < d->m_keycompose_size) {
|
||||
// found it -> simulate a Dead key press
|
||||
d->m_dead_unicode = unicode;
|
||||
unicode = 0xffff;
|
||||
d->m_composing = 1;
|
||||
skip = true;
|
||||
} else {
|
||||
d->m_composing = 0;
|
||||
}
|
||||
} else {
|
||||
d->m_composing = 0;
|
||||
}
|
||||
} else if (d->m_composing == 1 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
|
||||
// the last key press was a Dead key
|
||||
bool valid = false;
|
||||
if (unicode != 0xffff) {
|
||||
int idx = 0;
|
||||
// check if this code is in the compose table at all
|
||||
for ( ; idx < d->m_keycompose_size; ++idx) {
|
||||
if (d->m_keycompose[idx].first == d->m_dead_unicode && d->m_keycompose[idx].second == unicode)
|
||||
break;
|
||||
}
|
||||
if (idx < d->m_keycompose_size) {
|
||||
quint16 composed = d->m_keycompose[idx].result;
|
||||
if (composed != 0xffff) {
|
||||
unicode = composed;
|
||||
qtcode = Qt::Key_unknown;
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
unicode = d->m_dead_unicode;
|
||||
qtcode = Qt::Key_unknown;
|
||||
}
|
||||
d->m_composing = 0;
|
||||
}
|
||||
|
||||
if (!skip) {
|
||||
#ifdef QT_DEBUG_KEYMAP
|
||||
qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
|
||||
#endif
|
||||
|
||||
// send the result to the QWS server
|
||||
processKeyEvent(unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qkbd_qws.moc"
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
@ -1,103 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBD_QWS_H
|
||||
#define QKBD_QWS_H
|
||||
|
||||
#include <QtGui/qapplication.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
class QWSKbPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QWSKeyboardHandler
|
||||
{
|
||||
public:
|
||||
QWSKeyboardHandler();
|
||||
QWSKeyboardHandler(const QString &device);
|
||||
virtual ~QWSKeyboardHandler();
|
||||
|
||||
virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
|
||||
bool isPress, bool autoRepeat);
|
||||
|
||||
enum KeycodeAction {
|
||||
None = 0,
|
||||
|
||||
CapsLockOff = 0x01000000,
|
||||
CapsLockOn = 0x01000001,
|
||||
NumLockOff = 0x02000000,
|
||||
NumLockOn = 0x02000001,
|
||||
ScrollLockOff = 0x03000000,
|
||||
ScrollLockOn = 0x03000001,
|
||||
|
||||
Reboot = 0x04000000,
|
||||
|
||||
PreviousConsole = 0x05000000,
|
||||
NextConsole = 0x05000001,
|
||||
SwitchConsoleFirst = 0x06000000,
|
||||
SwitchConsoleLast = 0x0600007f,
|
||||
SwitchConsoleMask = 0x0000007f,
|
||||
};
|
||||
|
||||
KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat);
|
||||
|
||||
protected:
|
||||
int transformDirKey(int key);
|
||||
void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod);
|
||||
void endAutoRepeat();
|
||||
|
||||
private:
|
||||
QWSKbPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBD_QWS_H
|
@ -1,134 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSKEYBOARD_P_H
|
||||
#define QWSKEYBOARD_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 <QDataStream>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QWSKeyboard {
|
||||
const quint32 FileMagic = 0x514d4150; // 'QMAP'
|
||||
|
||||
struct Mapping {
|
||||
quint16 keycode;
|
||||
quint16 unicode;
|
||||
quint32 qtcode;
|
||||
quint8 modifiers;
|
||||
quint8 flags;
|
||||
quint16 special;
|
||||
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
IsDead = 0x01,
|
||||
IsLetter = 0x02,
|
||||
IsModifier = 0x04,
|
||||
IsSystem = 0x08,
|
||||
};
|
||||
|
||||
enum System {
|
||||
SystemConsoleFirst = 0x0100,
|
||||
SystemConsoleMask = 0x007f,
|
||||
SystemConsoleLast = 0x017f,
|
||||
SystemConsolePrevious = 0x0180,
|
||||
SystemConsoleNext = 0x0181,
|
||||
SystemReboot = 0x0200,
|
||||
SystemZap = 0x0300,
|
||||
};
|
||||
|
||||
struct Composing {
|
||||
quint16 first;
|
||||
quint16 second;
|
||||
quint16 result;
|
||||
};
|
||||
|
||||
enum Modifiers {
|
||||
ModPlain = 0x00,
|
||||
ModShift = 0x01,
|
||||
ModAltGr = 0x02,
|
||||
ModControl = 0x04,
|
||||
ModAlt = 0x08,
|
||||
ModShiftL = 0x10,
|
||||
ModShiftR = 0x20,
|
||||
ModCtrlL = 0x40,
|
||||
ModCtrlR = 0x80,
|
||||
// ModCapsShift = 0x100, // not supported!
|
||||
};
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Mapping &m)
|
||||
{
|
||||
return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
|
||||
}
|
||||
|
||||
inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Mapping &m)
|
||||
{
|
||||
return ds << m.keycode << m.unicode << m.qtcode << m.modifiers << m.flags << m.special;
|
||||
}
|
||||
|
||||
inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Composing &c)
|
||||
{
|
||||
return ds >> c.first >> c.second >> c.result;
|
||||
}
|
||||
|
||||
inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Composing &c)
|
||||
{
|
||||
return ds << c.first << c.second << c.result;
|
||||
}
|
||||
#endif // QT_NO_DATASTREAM
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWSKEYBOARD_H
|
@ -1,187 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbddriverfactory_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qkbdtty_qws.h"
|
||||
#include "qkbdlinuxinput_qws.h"
|
||||
#include "qkbdum_qws.h"
|
||||
#include "qkbdvfb_qws.h"
|
||||
#include "qkbdqnx_qws.h"
|
||||
#include "qkbdintegrity_qws.h"
|
||||
#include <stdlib.h>
|
||||
#include "private/qfactoryloader_p.h"
|
||||
#include "qkbddriverplugin_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QWSKeyboardHandlerFactoryInterface_iid,
|
||||
QLatin1String("/kbddrivers"), Qt::CaseInsensitive))
|
||||
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
|
||||
/*!
|
||||
\class QKbdDriverFactory
|
||||
\ingroup qws
|
||||
|
||||
\brief The QKbdDriverFactory class creates keyboard drivers in
|
||||
Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QKbdDriverFactory is used to detect and instantiate the available
|
||||
keyboard drivers, allowing \l{Qt for Embedded Linux} to load the preferred
|
||||
driver into the server application at runtime. The create()
|
||||
function returns a QWSKeyboardHandler object representing the
|
||||
keyboard driver identified by a given key. The valid keys
|
||||
(i.e. the supported drivers) can be retrieved using the keys()
|
||||
function.
|
||||
|
||||
\l{Qt for Embedded Linux} provides several built-in keyboard drivers. In
|
||||
addition, custom keyboard drivers can be added using Qt's plugin
|
||||
mechanism, i.e. by subclassing the QWSKeyboardHandler class and
|
||||
creating a keyboard driver plugin (QKbdDriverPlugin). See the
|
||||
\l{Qt for Embedded Linux Character Input}{character input} documentation
|
||||
for details.
|
||||
|
||||
\sa QWSKeyboardHandler, QKbdDriverPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Creates the keyboard driver specified by the given \a key, using
|
||||
the display specified by the given \a device.
|
||||
|
||||
Note that the keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& device)
|
||||
{
|
||||
QString driver = key.toLower();
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
|
||||
if (driver == QLatin1String("qnx") || driver.isEmpty())
|
||||
return new QWSQnxKeyboardHandler(device);
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY)
|
||||
if (driver == QLatin1String("integrity") || driver.isEmpty())
|
||||
return new QWSIntKeyboardHandler(device);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
# ifndef QT_NO_QWS_KBD_TTY
|
||||
if (driver == QLatin1String("tty") || driver.isEmpty())
|
||||
return new QWSTtyKeyboardHandler(device);
|
||||
# endif
|
||||
# ifndef QT_NO_QWS_KBD_LINUXINPUT
|
||||
if (driver == QLatin1String("linuxinput") || \
|
||||
driver == QLatin1String("usb") || \
|
||||
driver == QLatin1String("linuxis"))
|
||||
return new QWSLinuxInputKeyboardHandler(device);
|
||||
# endif
|
||||
# ifndef QT_NO_QWS_KBD_UM
|
||||
if (driver == QLatin1String("um") || driver == QLatin1String("qvfbkeyboard"))
|
||||
return new QWSUmKeyboardHandler(device);
|
||||
# endif
|
||||
# ifndef QT_NO_QWS_KBD_QVFB
|
||||
if (driver == QLatin1String("qvfbkbd")
|
||||
|| driver == QLatin1String("qvfbkeyboard")
|
||||
|| driver == QLatin1String("qvfb"))
|
||||
return new QVFbKeyboardHandler(device);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
if (QWSKeyboardHandlerFactoryInterface *factory = qobject_cast<QWSKeyboardHandlerFactoryInterface*>(loader()->instance(driver)))
|
||||
return factory->create(driver, device);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of valid keys, i.e. the available keyboard
|
||||
drivers.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
QStringList QKbdDriverFactory::keys()
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
|
||||
list << QLatin1String("QNX");
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_KBD_INTEGRITY)
|
||||
list << QLatin1String("INTEGRITY");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_KBD_TTY
|
||||
list << QLatin1String("TTY");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_KBD_LINUXINPUT
|
||||
list << QLatin1String("LinuxInput");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_KBD_UM
|
||||
list << QLatin1String("UM");
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
QStringList plugins = loader()->keys();
|
||||
for (int i = 0; i < plugins.size(); ++i) {
|
||||
if (!list.contains(plugins.at(i)))
|
||||
list += plugins.at(i);
|
||||
}
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
@ -1,70 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDDRIVERFACTORY_QWS_H
|
||||
#define QKBDDRIVERFACTORY_QWS_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QString;
|
||||
class QWSKeyboardHandler;
|
||||
|
||||
class Q_GUI_EXPORT QKbdDriverFactory
|
||||
{
|
||||
public:
|
||||
static QStringList keys();
|
||||
static QWSKeyboardHandler *create(const QString&, const QString&);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
#endif // QKBDDRIVERFACTORY_QWS_H
|
@ -1,124 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbddriverplugin_qws.h"
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
#include "qkbd_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QKbdDriverPlugin
|
||||
\ingroup plugins
|
||||
\ingroup qws
|
||||
|
||||
\brief The QKbdDriverPlugin class is an abstract base class for
|
||||
keyboard driver plugins in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
|
||||
protocols, see the \l{Qt for Embedded Linux Character Input}{character
|
||||
input} documentation for details. Custom keyboard drivers can be
|
||||
implemented by subclassing the QWSKeyboardHandler class and
|
||||
creating a keyboard driver plugin.
|
||||
|
||||
A keyboard driver plugin can be created by subclassing
|
||||
QKbdDriverPlugin and reimplementing the pure virtual keys() and
|
||||
create() functions. By exporting the derived class using the
|
||||
Q_EXPORT_PLUGIN2() macro, the default implementation of the
|
||||
QKbdDriverFactory class will automatically detect the plugin and
|
||||
load the driver into the server application at run-time. See
|
||||
\l{How to Create Qt Plugins} for details.
|
||||
|
||||
\sa QKbdDriverFactory, QWSKeyboardHandler
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QKbdDriverPlugin::keys() const
|
||||
|
||||
Implement this function to return the list of valid keys, i.e. the
|
||||
keyboard drivers supported by this plugin.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
|
||||
protocols, see the \l{Qt for Embedded Linux Character Input}{character
|
||||
input} documentation for details.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a keyboard driver plugin with the given \a parent.
|
||||
|
||||
Note that this constructor is invoked automatically by the
|
||||
Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
|
||||
explicitly.
|
||||
*/
|
||||
QKbdDriverPlugin::QKbdDriverPlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the keyboard driver plugin.
|
||||
|
||||
Note that Qt destroys a plugin automatically when it is no longer
|
||||
used, so there is no need for calling the destructor explicitly.
|
||||
*/
|
||||
QKbdDriverPlugin::~QKbdDriverPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QScreen *QKbdDriverPlugin::create(const QString &key, const QString &device)
|
||||
|
||||
Implement this function to create a driver matching the type
|
||||
specified by the given \a key and \a device parameters. Note that
|
||||
keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDDRIVERPLUGIN_QWS_H
|
||||
#define QKBDDRIVERPLUGIN_QWS_H
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
class QWSKeyboardHandler;
|
||||
|
||||
struct Q_GUI_EXPORT QWSKeyboardHandlerFactoryInterface : public QFactoryInterface
|
||||
{
|
||||
virtual QWSKeyboardHandler* create(const QString &name, const QString &device) = 0;
|
||||
};
|
||||
|
||||
#define QWSKeyboardHandlerFactoryInterface_iid "com.trolltech.Qt.QWSKeyboardHandlerFactoryInterface"
|
||||
Q_DECLARE_INTERFACE(QWSKeyboardHandlerFactoryInterface, QWSKeyboardHandlerFactoryInterface_iid)
|
||||
|
||||
class Q_GUI_EXPORT QKbdDriverPlugin : public QObject, public QWSKeyboardHandlerFactoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QWSKeyboardHandlerFactoryInterface:QFactoryInterface)
|
||||
public:
|
||||
explicit QKbdDriverPlugin(QObject *parent = 0);
|
||||
~QKbdDriverPlugin();
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QWSKeyboardHandler* create(const QString& driver, const QString &device) = 0;
|
||||
};
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDDRIVERPLUGIN_QWS_H
|
@ -1,197 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_INTEGRITY)
|
||||
|
||||
#include "qkbdintegrity_qws.h"
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qapplication.h>
|
||||
#include <qtimer.h>
|
||||
#include <qthread.h>
|
||||
|
||||
#include <INTEGRITY.h>
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
//
|
||||
// INTEGRITY keyboard
|
||||
//
|
||||
|
||||
class QIntKeyboardListenThread;
|
||||
|
||||
class QWSIntKbPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class QIntKeyboardListenThread;
|
||||
public:
|
||||
QWSIntKbPrivate(QWSKeyboardHandler *, const QString &device);
|
||||
~QWSIntKbPrivate();
|
||||
void dataReady(int amount) { emit kbdDataAvailable(amount); }
|
||||
uint8_t scancodebuf[32 /* USB_SCANCODE_BUF_LEN */ ];
|
||||
uint8_t rxpost;
|
||||
uint8_t rxack;
|
||||
|
||||
Q_SIGNALS:
|
||||
void kbdDataAvailable(int amount);
|
||||
|
||||
private Q_SLOTS:
|
||||
void readKeyboardData(int amount);
|
||||
|
||||
private:
|
||||
QWSKeyboardHandler *handler;
|
||||
QIntKeyboardListenThread *kbdthread;
|
||||
};
|
||||
class QIntKeyboardListenThread : public QThread
|
||||
{
|
||||
protected:
|
||||
QWSIntKbPrivate *imp;
|
||||
bool loop;
|
||||
public:
|
||||
QIntKeyboardListenThread(QWSIntKbPrivate *im) : QThread(), imp(im) {};
|
||||
~QIntKeyboardListenThread() {};
|
||||
void run();
|
||||
void stoploop() { loop = false; };
|
||||
};
|
||||
|
||||
|
||||
QWSIntKeyboardHandler::QWSIntKeyboardHandler(const QString &device)
|
||||
: QWSKeyboardHandler(device)
|
||||
{
|
||||
d = new QWSIntKbPrivate(this, device);
|
||||
}
|
||||
|
||||
QWSIntKeyboardHandler::~QWSIntKeyboardHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
//void QWSIntKeyboardHandler::processKeyEvent(int keycode, bool isPress,
|
||||
// bool autoRepeat)
|
||||
//{
|
||||
// QWSKeyboardHandler::processKeyEvent(keycode, isPress, autoRepeat);
|
||||
//}
|
||||
|
||||
void QIntKeyboardListenThread::run(void)
|
||||
{
|
||||
Error E;
|
||||
Buffer b;
|
||||
Connection kbdc;
|
||||
bool waitforresource = true;
|
||||
do {
|
||||
E = RequestResource((Object*)&kbdc,
|
||||
"USBKeyboardClient", "!systempassword");
|
||||
if (E == Success) {
|
||||
loop = false;
|
||||
} else {
|
||||
E = RequestResource((Object*)&kbdc,
|
||||
"KeyboardClient", "!systempassword");
|
||||
if (E == Success) {
|
||||
waitforresource = false;
|
||||
}
|
||||
}
|
||||
if (waitforresource)
|
||||
::sleep(1);
|
||||
} while (loop && waitforresource);
|
||||
if (!loop)
|
||||
return;
|
||||
b.BufferType = DataBuffer | LastBuffer;
|
||||
b.Length = sizeof(imp->scancodebuf);
|
||||
b.TheAddress = (Address)imp->scancodebuf;
|
||||
do {
|
||||
b.Transferred = 0;
|
||||
b.TheAddress = (Address)imp->scancodebuf + imp->rxpost;
|
||||
CheckSuccess(SynchronousReceive(kbdc, &b));
|
||||
imp->rxpost += b.Transferred;
|
||||
if (imp->rxpost >= 32 /* USB_SCANCODE_BUF_LEN */)
|
||||
imp->rxpost = 0;
|
||||
if (imp->rxpost == (imp->rxack + b.Transferred) % 32 /* USB_SCANCODE_BUF_LEN */) {
|
||||
imp->kbdDataAvailable(b.Transferred);
|
||||
}
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
void QWSIntKbPrivate::readKeyboardData(int amount)
|
||||
{
|
||||
uint16_t keycode;
|
||||
do {
|
||||
if (scancodebuf[rxack] == 0xe0) {
|
||||
keycode = scancodebuf[rxack] << 8;
|
||||
rxack++;
|
||||
if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
|
||||
rxack = 0;
|
||||
} else {
|
||||
keycode = 0;
|
||||
}
|
||||
|
||||
handler->processKeycode(keycode + (scancodebuf[rxack] & 0x7f),
|
||||
(scancodebuf[rxack] & 0x80) == 0,
|
||||
scancodebuf[rxack] == 2);
|
||||
rxack++;
|
||||
if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
|
||||
rxack = 0;
|
||||
} while (rxack != rxpost);
|
||||
}
|
||||
|
||||
QWSIntKbPrivate::QWSIntKbPrivate(QWSKeyboardHandler *h, const QString &device) : handler(h)
|
||||
{
|
||||
connect(this, SIGNAL(kbdDataAvailable(int)), this, SLOT(readKeyboardData(int)));
|
||||
this->handler = handler;
|
||||
rxack = rxpost = 0;
|
||||
kbdthread = new QIntKeyboardListenThread(this);
|
||||
kbdthread->start();
|
||||
}
|
||||
|
||||
QWSIntKbPrivate::~QWSIntKbPrivate()
|
||||
{
|
||||
kbdthread->stoploop();
|
||||
kbdthread->wait();
|
||||
delete kbdthread;
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qkbdintegrity_qws.moc"
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD || QT_NO_QWS_KBD_TTY
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDINTEGRITY_QWS_H
|
||||
#define QKBDINTEGRITY_QWS_H
|
||||
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#ifndef QT_NO_QWS_KBD_INTEGRITY
|
||||
|
||||
class QSocketNotifier;
|
||||
class QWSIntKbPrivate;
|
||||
|
||||
class QWSIntKeyboardHandler : public QWSKeyboardHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSIntKeyboardHandler(const QString&);
|
||||
virtual ~QWSIntKeyboardHandler();
|
||||
|
||||
//protected:
|
||||
// virtual void processKeyEvent(int keycode, bool isPress, bool autoRepeat);
|
||||
|
||||
private:
|
||||
QWSIntKbPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KBD_INTEGRITY
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDINTEGRITY_QWS_H
|
@ -1,245 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbdlinuxinput_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#include <QSocketNotifier>
|
||||
#include <QStringList>
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <linux/kd.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QWSLinuxInputKbPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *, const QString &);
|
||||
~QWSLinuxInputKbPrivate();
|
||||
|
||||
private:
|
||||
void switchLed(int, bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void readKeycode();
|
||||
|
||||
private:
|
||||
QWSLinuxInputKeyboardHandler *m_handler;
|
||||
int m_fd;
|
||||
int m_tty_fd;
|
||||
struct termios m_tty_attr;
|
||||
int m_orig_kbmode;
|
||||
};
|
||||
|
||||
QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device)
|
||||
: QWSKeyboardHandler(device)
|
||||
{
|
||||
d = new QWSLinuxInputKbPrivate(this, device);
|
||||
}
|
||||
|
||||
QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device)
|
||||
: m_handler(h), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE)
|
||||
{
|
||||
setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler"));
|
||||
|
||||
QString dev = QLatin1String("/dev/input/event1");
|
||||
int repeat_delay = -1;
|
||||
int repeat_rate = -1;
|
||||
|
||||
QStringList args = device.split(QLatin1Char(':'));
|
||||
foreach (const QString &arg, args) {
|
||||
if (arg.startsWith(QLatin1String("repeat-delay=")))
|
||||
repeat_delay = arg.mid(13).toInt();
|
||||
else if (arg.startsWith(QLatin1String("repeat-rate=")))
|
||||
repeat_rate = arg.mid(12).toInt();
|
||||
else if (arg.startsWith(QLatin1String("/dev/")))
|
||||
dev = arg;
|
||||
}
|
||||
|
||||
m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
|
||||
if (m_fd >= 0) {
|
||||
if (repeat_delay > 0 && repeat_rate > 0) {
|
||||
int kbdrep[2] = { repeat_delay, repeat_rate };
|
||||
::ioctl(m_fd, EVIOCSREP, kbdrep);
|
||||
}
|
||||
|
||||
QSocketNotifier *notifier;
|
||||
notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
|
||||
connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
|
||||
|
||||
// play nice in case we are started from a shell (e.g. for debugging)
|
||||
m_tty_fd = isatty(0) ? 0 : -1;
|
||||
|
||||
if (m_tty_fd >= 0) {
|
||||
// save tty config for restore.
|
||||
tcgetattr(m_tty_fd, &m_tty_attr);
|
||||
|
||||
struct ::termios termdata;
|
||||
tcgetattr(m_tty_fd, &termdata);
|
||||
|
||||
// record the original mode so we can restore it again in the destructor.
|
||||
::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
|
||||
|
||||
// setting this translation mode is even needed in INPUT mode to prevent
|
||||
// the shell from also interpreting codes, if the process has a tty
|
||||
// attached: e.g. Ctrl+C wouldn't copy, but kill the application.
|
||||
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
|
||||
|
||||
// set the tty layer to pass-through
|
||||
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
||||
termdata.c_oflag = 0;
|
||||
termdata.c_cflag = CREAD | CS8;
|
||||
termdata.c_lflag = 0;
|
||||
termdata.c_cc[VTIME]=0;
|
||||
termdata.c_cc[VMIN]=1;
|
||||
cfsetispeed(&termdata, 9600);
|
||||
cfsetospeed(&termdata, 9600);
|
||||
tcsetattr(m_tty_fd, TCSANOW, &termdata);
|
||||
}
|
||||
} else {
|
||||
qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate()
|
||||
{
|
||||
if (m_tty_fd >= 0) {
|
||||
::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
|
||||
tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
|
||||
}
|
||||
if (m_fd >= 0)
|
||||
QT_CLOSE(m_fd);
|
||||
}
|
||||
|
||||
void QWSLinuxInputKbPrivate::switchLed(int led, bool state)
|
||||
{
|
||||
struct ::input_event led_ie;
|
||||
::gettimeofday(&led_ie.time, 0);
|
||||
led_ie.type = EV_LED;
|
||||
led_ie.code = led;
|
||||
led_ie.value = state;
|
||||
|
||||
QT_WRITE(m_fd, &led_ie, sizeof(led_ie));
|
||||
}
|
||||
|
||||
void QWSLinuxInputKbPrivate::readKeycode()
|
||||
{
|
||||
struct ::input_event buffer[32];
|
||||
int n = 0;
|
||||
|
||||
forever {
|
||||
n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
|
||||
|
||||
if (n == 0) {
|
||||
qWarning("Got EOF from the input device.");
|
||||
return;
|
||||
} else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
|
||||
qWarning("Could not read from input device: %s", strerror(errno));
|
||||
return;
|
||||
} else if (n % sizeof(buffer[0]) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
n /= sizeof(buffer[0]);
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (buffer[i].type != EV_KEY)
|
||||
continue;
|
||||
|
||||
quint16 code = buffer[i].code;
|
||||
qint32 value = buffer[i].value;
|
||||
|
||||
if (m_handler->filterInputEvent(code, value))
|
||||
continue;
|
||||
|
||||
QWSKeyboardHandler::KeycodeAction ka;
|
||||
ka = m_handler->processKeycode(code, value != 0, value == 2);
|
||||
|
||||
switch (ka) {
|
||||
case QWSKeyboardHandler::CapsLockOn:
|
||||
case QWSKeyboardHandler::CapsLockOff:
|
||||
switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn);
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::NumLockOn:
|
||||
case QWSKeyboardHandler::NumLockOff:
|
||||
switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn);
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::ScrollLockOn:
|
||||
case QWSKeyboardHandler::ScrollLockOff:
|
||||
switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn);
|
||||
break;
|
||||
|
||||
default:
|
||||
// ignore console switching and reboot
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qkbdlinuxinput_qws.moc"
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDLINUXINPUT_QWS_H
|
||||
#define QKBDLINUXINPUT_QWS_H
|
||||
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#ifndef QT_NO_QWS_KBD_LINUXINPUT
|
||||
|
||||
class QWSLinuxInputKbPrivate;
|
||||
|
||||
class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler
|
||||
{
|
||||
public:
|
||||
QWSLinuxInputKeyboardHandler(const QString&);
|
||||
virtual ~QWSLinuxInputKeyboardHandler();
|
||||
|
||||
virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value);
|
||||
|
||||
private:
|
||||
QWSLinuxInputKbPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KBD_LINUXINPUT
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDLINUXINPUT_QWS_H
|
@ -1,236 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbdqnx_qws.h"
|
||||
#include "QtCore/qsocketnotifier.h"
|
||||
#include "QtCore/qdebug.h"
|
||||
|
||||
#include <sys/dcmd_input.h>
|
||||
#include <photon/keycodes.h>
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QWSQnxKeyboardHandler
|
||||
\preliminary
|
||||
\ingroup qws
|
||||
\since 4.6
|
||||
\internal
|
||||
|
||||
\brief The QWSQnxKeyboardHandler class implements a keyboard driver
|
||||
for the QNX \c{devi-hid} input manager.
|
||||
|
||||
To be able to compile this mouse handler, \l{Qt for Embedded Linux}
|
||||
must be configured with the \c -qt-kbd-qnx option, see the
|
||||
\l{Qt for Embedded Linux Character Input} documentation for details.
|
||||
|
||||
In order to use this keyboard handler, the \c{devi-hid} input manager
|
||||
must be set up and run with the resource manager interface (option \c{-r}).
|
||||
Also, Photon must not be running.
|
||||
|
||||
Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
|
||||
Note that after running \c{devi-hid}, you will not be able to use the local
|
||||
shell anymore. It is suggested to run the command in a shell scrip, that launches
|
||||
a Qt application after invocation of \c{devi-hid}.
|
||||
|
||||
To make \l{Qt for Embedded Linux} explicitly choose the qnx keyboard
|
||||
handler, set the QWS_KEYBOARD environment variable to \c{qnx}. By default,
|
||||
the first keyboard device (\c{/dev/devi/keyboard0}) is used. To override, pass a device
|
||||
name as the first and only parameter, for example
|
||||
\c{QWS_KEYBOARD=qnx:/dev/devi/keyboard1; export QWS_KEYBOARD}.
|
||||
|
||||
\sa {Qt for Embedded Linux Character Input}, {Qt for Embedded Linux}
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a keyboard handler for the specified \a device, defaulting to
|
||||
\c{/dev/devi/keyboard0}.
|
||||
|
||||
Note that you should never instanciate this class, instead let QKbdDriverFactory
|
||||
handle the keyboard handlers.
|
||||
|
||||
\sa QKbdDriverFactory
|
||||
*/
|
||||
QWSQnxKeyboardHandler::QWSQnxKeyboardHandler(const QString &device)
|
||||
{
|
||||
// open the keyboard device
|
||||
keyboardFD = QT_OPEN(device.isEmpty() ? "/dev/devi/keyboard0" : device.toLatin1().constData(),
|
||||
QT_OPEN_RDONLY);
|
||||
if (keyboardFD == -1) {
|
||||
qErrnoWarning(errno, "QWSQnxKeyboardHandler: Unable to open device");
|
||||
return;
|
||||
}
|
||||
|
||||
// create a socket notifier so we'll wake up whenever keyboard input is detected.
|
||||
QSocketNotifier *notifier = new QSocketNotifier(keyboardFD, QSocketNotifier::Read, this);
|
||||
connect(notifier, SIGNAL(activated(int)), SLOT(socketActivated()));
|
||||
|
||||
qDebug() << "QWSQnxKeyboardHandler: connected.";
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this keyboard handler and closes the connection to the keyboard device.
|
||||
*/
|
||||
QWSQnxKeyboardHandler::~QWSQnxKeyboardHandler()
|
||||
{
|
||||
QT_CLOSE(keyboardFD);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Translates the QNX keyboard events to Qt keyboard events
|
||||
*/
|
||||
void QWSQnxKeyboardHandler::socketActivated()
|
||||
{
|
||||
_keyboard_packet packet;
|
||||
|
||||
// read one keyboard event
|
||||
int bytesRead = QT_READ(keyboardFD, &packet, sizeof(_keyboard_packet));
|
||||
if (bytesRead == -1) {
|
||||
qErrnoWarning(errno, "QWSQnxKeyboardHandler::socketActivated(): Unable to read data.");
|
||||
return;
|
||||
}
|
||||
|
||||
// the bytes read must be the size of a keyboard packet
|
||||
Q_ASSERT(bytesRead == sizeof(_keyboard_packet));
|
||||
|
||||
#if 0
|
||||
qDebug() << "keyboard got scancode"
|
||||
<< hex << packet.data.modifiers
|
||||
<< packet.data.flags
|
||||
<< packet.data.key_cap
|
||||
<< packet.data.key_sym
|
||||
<< packet.data.key_scan;
|
||||
#endif
|
||||
|
||||
// QNX is nice enough to translate the raw keyboard data into a QNX data structure
|
||||
// Now we just have to translate it into a format Qt understands.
|
||||
|
||||
// figure out whether it's a press
|
||||
bool isPress = packet.data.key_cap & KEY_DOWN;
|
||||
// figure out whether the key is still pressed and the key event is repeated
|
||||
bool isRepeat = packet.data.key_cap & KEY_REPEAT;
|
||||
|
||||
Qt::Key key = Qt::Key_unknown;
|
||||
int unicode = 0xffff;
|
||||
|
||||
// TODO - this switch is not complete!
|
||||
switch (packet.data.key_scan) {
|
||||
case KEYCODE_SPACE: key = Qt::Key_Space; unicode = 0x20; break;
|
||||
case KEYCODE_F1: key = Qt::Key_F1; break;
|
||||
case KEYCODE_F2: key = Qt::Key_F2; break;
|
||||
case KEYCODE_F3: key = Qt::Key_F3; break;
|
||||
case KEYCODE_F4: key = Qt::Key_F4; break;
|
||||
case KEYCODE_F5: key = Qt::Key_F5; break;
|
||||
case KEYCODE_F6: key = Qt::Key_F6; break;
|
||||
case KEYCODE_F7: key = Qt::Key_F7; break;
|
||||
case KEYCODE_F8: key = Qt::Key_F8; break;
|
||||
case KEYCODE_F9: key = Qt::Key_F9; break;
|
||||
case KEYCODE_F10: key = Qt::Key_F10; break;
|
||||
case KEYCODE_F11: key = Qt::Key_F11; break;
|
||||
case KEYCODE_F12: key = Qt::Key_F12; break;
|
||||
case KEYCODE_BACKSPACE: key = Qt::Key_Backspace; break;
|
||||
case KEYCODE_TAB: key = Qt::Key_Tab; break;
|
||||
case KEYCODE_RETURN: key = Qt::Key_Return; break;
|
||||
case KEYCODE_KP_ENTER: key = Qt::Key_Enter; break;
|
||||
case KEYCODE_UP:
|
||||
case KEYCODE_KP_UP:
|
||||
key = Qt::Key_Up; break;
|
||||
case KEYCODE_DOWN:
|
||||
case KEYCODE_KP_DOWN:
|
||||
key = Qt::Key_Down; break;
|
||||
case KEYCODE_LEFT:
|
||||
case KEYCODE_KP_LEFT:
|
||||
key = Qt::Key_Left; break;
|
||||
case KEYCODE_RIGHT:
|
||||
case KEYCODE_KP_RIGHT:
|
||||
key = Qt::Key_Right; break;
|
||||
case KEYCODE_HOME:
|
||||
case KEYCODE_KP_HOME:
|
||||
key = Qt::Key_Home; break;
|
||||
case KEYCODE_END:
|
||||
case KEYCODE_KP_END:
|
||||
key = Qt::Key_End; break;
|
||||
case KEYCODE_PG_UP:
|
||||
case KEYCODE_KP_PG_UP:
|
||||
key = Qt::Key_PageUp; break;
|
||||
case KEYCODE_PG_DOWN:
|
||||
case KEYCODE_KP_PG_DOWN:
|
||||
key = Qt::Key_PageDown; break;
|
||||
case KEYCODE_INSERT:
|
||||
case KEYCODE_KP_INSERT:
|
||||
key = Qt::Key_Insert; break;
|
||||
case KEYCODE_DELETE:
|
||||
case KEYCODE_KP_DELETE:
|
||||
key = Qt::Key_Delete; break;
|
||||
case KEYCODE_ESCAPE:
|
||||
key = Qt::Key_Escape; break;
|
||||
default: // none of the above, try the key_scan directly
|
||||
unicode = packet.data.key_scan;
|
||||
break;
|
||||
}
|
||||
|
||||
// figure out the modifiers that are currently pressed
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
|
||||
if (packet.data.flags & KEYMOD_SHIFT)
|
||||
modifiers |= Qt::ShiftModifier;
|
||||
if (packet.data.flags & KEYMOD_CTRL)
|
||||
modifiers |= Qt::ControlModifier;
|
||||
if (packet.data.flags & KEYMOD_ALT)
|
||||
modifiers |= Qt::AltModifier;
|
||||
|
||||
// if the unicode value is not ascii, we ignore it.
|
||||
// TODO - do a complete mapping between all QNX scan codes and Qt codes
|
||||
if (unicode != 0xffff && !isascii(unicode))
|
||||
return; // unprintable character
|
||||
|
||||
// call processKeyEvent. This is where all the magic happens to insert a
|
||||
// key event into Qt's event loop.
|
||||
// Note that for repeated key events, isPress must be true
|
||||
// (on QNX, isPress is not set when the key event is repeated).
|
||||
processKeyEvent(unicode, key, modifiers, isPress || isRepeat, isRepeat);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,76 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDQNX_QWS_H
|
||||
#define QKBDQNX_QWS_H
|
||||
|
||||
#include <QtGui/qapplication.h>
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_QNX)
|
||||
|
||||
class Q_GUI_EXPORT QWSQnxKeyboardHandler : public QObject, public QWSKeyboardHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSQnxKeyboardHandler(const QString &device);
|
||||
~QWSQnxKeyboardHandler();
|
||||
|
||||
private Q_SLOTS:
|
||||
void socketActivated();
|
||||
|
||||
private:
|
||||
int keyboardFD;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDQNX_QWS_H
|
@ -1,353 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbdtty_qws.h"
|
||||
|
||||
#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_TTY)
|
||||
|
||||
#include <QSocketNotifier>
|
||||
#include <QStringList>
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
|
||||
#if defined Q_OS_LINUX
|
||||
# include <linux/kd.h>
|
||||
# include <linux/vt.h> //TODO: move vt handling somewhere else (QLinuxFbScreen?)
|
||||
|
||||
# include "qscreen_qws.h"
|
||||
# include "qwindowsystem_qws.h"
|
||||
# include "qapplication.h"
|
||||
# include "private/qwindowsurface_qws_p.h"
|
||||
# include "private/qwssignalhandler_p.h"
|
||||
|
||||
# define VTACQSIG SIGUSR1
|
||||
# define VTRELSIG SIGUSR2
|
||||
#endif
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWSTtyKbPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSTtyKbPrivate(QWSTtyKeyboardHandler *handler, const QString &device);
|
||||
~QWSTtyKbPrivate();
|
||||
|
||||
private:
|
||||
void switchLed(char, bool);
|
||||
void switchConsole(int vt);
|
||||
|
||||
private Q_SLOTS:
|
||||
void readKeycode();
|
||||
void handleConsoleSwitch(int sig);
|
||||
|
||||
private:
|
||||
QWSTtyKeyboardHandler *m_handler;
|
||||
int m_tty_fd;
|
||||
struct termios m_tty_attr;
|
||||
char m_last_keycode;
|
||||
int m_vt_qws;
|
||||
int m_orig_kbmode;
|
||||
};
|
||||
|
||||
|
||||
QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device)
|
||||
: QWSKeyboardHandler(device)
|
||||
{
|
||||
d = new QWSTtyKbPrivate(this, device);
|
||||
}
|
||||
|
||||
QWSTtyKeyboardHandler::~QWSTtyKeyboardHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QWSTtyKeyboardHandler::filterKeycode(char &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device)
|
||||
: m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0), m_orig_kbmode(K_XLATE)
|
||||
{
|
||||
setObjectName(QLatin1String("TTY Keyboard Handler"));
|
||||
#ifndef QT_NO_QWS_SIGNALHANDLER
|
||||
QWSSignalHandler::instance()->addObject(this);
|
||||
#endif
|
||||
|
||||
QString dev = QLatin1String("/dev/tty0");
|
||||
int repeat_delay = -1;
|
||||
int repeat_rate = -1;
|
||||
|
||||
QStringList args = device.split(QLatin1Char(':'));
|
||||
foreach (const QString &arg, args) {
|
||||
if (arg.startsWith(QLatin1String("repeat-delay=")))
|
||||
repeat_delay = arg.mid(13).toInt();
|
||||
else if (arg.startsWith(QLatin1String("repeat-rate=")))
|
||||
repeat_rate = arg.mid(12).toInt();
|
||||
else if (arg.startsWith(QLatin1String("/dev/")))
|
||||
dev = arg;
|
||||
}
|
||||
|
||||
m_tty_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
|
||||
if (m_tty_fd >= 0) {
|
||||
if (repeat_delay > 0 && repeat_rate > 0) {
|
||||
#if defined(Q_OS_LINUX)
|
||||
struct ::kbd_repeat kbdrep = { repeat_delay, repeat_rate };
|
||||
::ioctl(m_tty_fd, KDKBDREP, &kbdrep);
|
||||
#endif
|
||||
}
|
||||
|
||||
QSocketNotifier *notifier;
|
||||
notifier = new QSocketNotifier(m_tty_fd, QSocketNotifier::Read, this);
|
||||
connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
|
||||
|
||||
// save tty config for restore.
|
||||
tcgetattr(m_tty_fd, &m_tty_attr);
|
||||
|
||||
struct ::termios termdata;
|
||||
tcgetattr(m_tty_fd, &termdata);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
// record the original mode so we can restore it again in the destructor.
|
||||
::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
|
||||
|
||||
// PLEASE NOTE:
|
||||
// the tty keycode interface can only report keycodes 0x01 .. 0x7f
|
||||
// KEY_MAX is however defined to 0x1ff. In practice this is sufficient
|
||||
// for a PC style keyboard though.
|
||||
// we don't support K_RAW anymore - if you need that, you have to add
|
||||
// a scan- to keycode converter yourself.
|
||||
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
|
||||
#endif
|
||||
|
||||
// set the tty layer to pass-through
|
||||
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
||||
termdata.c_oflag = 0;
|
||||
termdata.c_cflag = CREAD | CS8;
|
||||
termdata.c_lflag = 0;
|
||||
termdata.c_cc[VTIME]=0;
|
||||
termdata.c_cc[VMIN]=1;
|
||||
cfsetispeed(&termdata, 9600);
|
||||
cfsetospeed(&termdata, 9600);
|
||||
tcsetattr(m_tty_fd, TCSANOW, &termdata);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
// VT switching is handled via unix signals
|
||||
connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleConsoleSwitch(int)));
|
||||
QApplication::instance()->watchUnixSignal(VTACQSIG, true);
|
||||
QApplication::instance()->watchUnixSignal(VTRELSIG, true);
|
||||
|
||||
struct ::vt_mode vtMode;
|
||||
if (::ioctl(m_tty_fd, VT_GETMODE, &vtMode) == 0) {
|
||||
vtMode.mode = VT_PROCESS;
|
||||
vtMode.relsig = VTRELSIG;
|
||||
vtMode.acqsig = VTACQSIG;
|
||||
|
||||
if (::ioctl(m_tty_fd, VT_SETMODE, &vtMode) == 0) {
|
||||
struct ::vt_stat vtStat;
|
||||
::memset(&vtStat, 0, sizeof(vtStat));
|
||||
|
||||
if (::ioctl(m_tty_fd, VT_GETSTATE, &vtStat) == 0 ) {
|
||||
m_vt_qws = vtStat.v_active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_vt_qws)
|
||||
qWarning("Could not initialize virtual console switching");
|
||||
#endif
|
||||
} else {
|
||||
qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QWSTtyKbPrivate::~QWSTtyKbPrivate()
|
||||
{
|
||||
if (m_tty_fd >= 0) {
|
||||
#if defined(Q_OS_LINUX)
|
||||
::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
|
||||
#endif
|
||||
tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
|
||||
QT_CLOSE(m_tty_fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QWSTtyKbPrivate::switchLed(char led, bool state)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
char ledstate;
|
||||
|
||||
::ioctl(m_tty_fd, KDGETLED, &ledstate);
|
||||
if (state)
|
||||
ledstate |= led;
|
||||
else
|
||||
ledstate &= ~led;
|
||||
::ioctl(m_tty_fd, KDSETLED, ledstate);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWSTtyKbPrivate::readKeycode()
|
||||
{
|
||||
char buffer[32];
|
||||
int n = 0;
|
||||
|
||||
forever {
|
||||
n = QT_READ(m_tty_fd, buffer + n, 32 - n);
|
||||
|
||||
if (n == 0) {
|
||||
qWarning("Got EOF from the input device.");
|
||||
return;
|
||||
} else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
|
||||
qWarning("Could not read from input device: %s", strerror(errno));
|
||||
return;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (m_handler->filterKeycode(buffer[i]))
|
||||
continue;
|
||||
|
||||
QWSKeyboardHandler::KeycodeAction ka;
|
||||
ka = m_handler->processKeycode(buffer[i] & 0x7f, (buffer[i] & 0x80) == 0x00, buffer[i] == m_last_keycode);
|
||||
m_last_keycode = buffer[i];
|
||||
|
||||
switch (ka) {
|
||||
case QWSKeyboardHandler::CapsLockOn:
|
||||
case QWSKeyboardHandler::CapsLockOff:
|
||||
switchLed(LED_CAP, ka == QWSKeyboardHandler::CapsLockOn);
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::NumLockOn:
|
||||
case QWSKeyboardHandler::NumLockOff:
|
||||
switchLed(LED_NUM, ka == QWSKeyboardHandler::NumLockOn);
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::ScrollLockOn:
|
||||
case QWSKeyboardHandler::ScrollLockOff:
|
||||
switchLed(LED_SCR, ka == QWSKeyboardHandler::ScrollLockOn);
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::PreviousConsole:
|
||||
switchConsole(qBound(1, m_vt_qws - 1, 10));
|
||||
break;
|
||||
|
||||
case QWSKeyboardHandler::NextConsole:
|
||||
switchConsole(qBound(1, m_vt_qws + 1, 10));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ka >= QWSKeyboardHandler::SwitchConsoleFirst &&
|
||||
ka <= QWSKeyboardHandler::SwitchConsoleLast) {
|
||||
switchConsole(1 + (ka & QWSKeyboardHandler::SwitchConsoleMask));
|
||||
}
|
||||
//ignore reboot
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QWSTtyKbPrivate::switchConsole(int vt)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
if (m_vt_qws && vt && (m_tty_fd >= 0 ))
|
||||
::ioctl(m_tty_fd, VT_ACTIVATE, vt);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWSTtyKbPrivate::handleConsoleSwitch(int sig)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
// received a notification from the kernel that the current VT is
|
||||
// changing: either enable or disable QWS painting accordingly.
|
||||
|
||||
if (sig == VTACQSIG) {
|
||||
if (::ioctl(m_tty_fd, VT_RELDISP, VT_ACKACQ) == 0) {
|
||||
qwsServer->enablePainting(true);
|
||||
qt_screen->restore();
|
||||
qwsServer->resumeMouse();
|
||||
qwsServer->refresh();
|
||||
}
|
||||
} else if (sig == VTRELSIG) {
|
||||
qwsServer->enablePainting(false);
|
||||
|
||||
// Check for reserved surfaces which might still do painting
|
||||
bool allWindowsHidden = true;
|
||||
const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
|
||||
for (int i = 0; i < windows.size(); ++i) {
|
||||
const QWSWindow *w = windows.at(i);
|
||||
QWSWindowSurface *s = w->windowSurface();
|
||||
if (s && s->isRegionReserved() && !w->allocatedRegion().isEmpty()) {
|
||||
allWindowsHidden = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allWindowsHidden) {
|
||||
::ioctl(m_tty_fd, VT_RELDISP, 0); // abort console switch
|
||||
qwsServer->enablePainting(true);
|
||||
} else if (::ioctl(m_tty_fd, VT_RELDISP, 1) == 0) {
|
||||
qt_screen->save();
|
||||
qwsServer->suspendMouse();
|
||||
} else {
|
||||
qwsServer->enablePainting(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qkbdtty_qws.moc"
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD || QT_NO_QWS_KBD_TTY
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDTTY_QWS_H
|
||||
#define QKBDTTY_QWS_H
|
||||
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#ifndef QT_NO_QWS_KBD_TTY
|
||||
|
||||
class QWSTtyKbPrivate;
|
||||
|
||||
class QWSTtyKeyboardHandler : public QWSKeyboardHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSTtyKeyboardHandler(const QString&);
|
||||
virtual ~QWSTtyKeyboardHandler();
|
||||
|
||||
virtual bool filterKeycode(char &code);
|
||||
|
||||
private:
|
||||
QWSTtyKbPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KBD_TTY
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDTTY_QWS_H
|
@ -1,144 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkbdum_qws.h"
|
||||
#include "qvfbhdr.h"
|
||||
|
||||
#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_UM)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include "qplatformdefs.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWSUmKeyboardHandlerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QWSUmKeyboardHandlerPrivate(const QString&);
|
||||
~QWSUmKeyboardHandlerPrivate();
|
||||
|
||||
private slots:
|
||||
void readKeyboardData();
|
||||
|
||||
private:
|
||||
int kbdFD;
|
||||
int kbdIdx;
|
||||
const int kbdBufferLen;
|
||||
unsigned char *kbdBuffer;
|
||||
QSocketNotifier *notifier;
|
||||
};
|
||||
|
||||
QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device)
|
||||
: kbdFD(-1), kbdIdx(0), kbdBufferLen(sizeof(QVFbKeyData)*5)
|
||||
{
|
||||
kbdBuffer = new unsigned char [kbdBufferLen];
|
||||
|
||||
if ((kbdFD = QT_OPEN((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY, 0)) < 0) {
|
||||
qDebug("Cannot open %s (%s)", (const char *)device.toLocal8Bit(),
|
||||
strerror(errno));
|
||||
} else {
|
||||
// Clear pending input
|
||||
char buf[2];
|
||||
while (QT_READ(kbdFD, buf, 1) > 0) { }
|
||||
|
||||
notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
|
||||
connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
|
||||
}
|
||||
}
|
||||
|
||||
QWSUmKeyboardHandlerPrivate::~QWSUmKeyboardHandlerPrivate()
|
||||
{
|
||||
if (kbdFD >= 0)
|
||||
QT_CLOSE(kbdFD);
|
||||
delete [] kbdBuffer;
|
||||
}
|
||||
|
||||
|
||||
void QWSUmKeyboardHandlerPrivate::readKeyboardData()
|
||||
{
|
||||
int n;
|
||||
do {
|
||||
n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
|
||||
if (n > 0)
|
||||
kbdIdx += n;
|
||||
} while (n > 0);
|
||||
|
||||
int idx = 0;
|
||||
while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) {
|
||||
QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx);
|
||||
// Qtopia Key filters must still work.
|
||||
QWSServer::processKeyEvent(kd->unicode, kd->keycode, kd->modifiers, kd->press, kd->repeat);
|
||||
idx += sizeof(QVFbKeyData);
|
||||
}
|
||||
|
||||
int surplus = kbdIdx - idx;
|
||||
for (int i = 0; i < surplus; i++)
|
||||
kbdBuffer[i] = kbdBuffer[idx+i];
|
||||
kbdIdx = surplus;
|
||||
}
|
||||
|
||||
QWSUmKeyboardHandler::QWSUmKeyboardHandler(const QString &device)
|
||||
: QWSKeyboardHandler()
|
||||
{
|
||||
d = new QWSUmKeyboardHandlerPrivate(device);
|
||||
}
|
||||
|
||||
QWSUmKeyboardHandler::~QWSUmKeyboardHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qkbdum_qws.moc"
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD && QT_NO_QWS_KBD_UM
|
@ -1,77 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDUM_QWS_H
|
||||
#define QKBDUM_QWS_H
|
||||
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#ifndef QT_NO_QWS_KBD_UM
|
||||
|
||||
class QWSUmKeyboardHandlerPrivate;
|
||||
|
||||
class QWSUmKeyboardHandler : public QWSKeyboardHandler
|
||||
{
|
||||
public:
|
||||
QWSUmKeyboardHandler(const QString &);
|
||||
virtual ~QWSUmKeyboardHandler();
|
||||
|
||||
private:
|
||||
|
||||
QWSUmKeyboardHandlerPrivate *d;
|
||||
};
|
||||
#endif // QT_NO_QWS_KBD_UM
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDUM_QWS_H
|
@ -1,124 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <qvfbhdr.h>
|
||||
#include <qkbdvfb_qws.h>
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
#ifndef QT_NO_QWS_KBD_QVFB
|
||||
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include <qapplication.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
|
||||
: QObject()
|
||||
{
|
||||
terminalName = device;
|
||||
if (terminalName.isEmpty())
|
||||
terminalName = QLatin1String("/dev/vkdb");
|
||||
kbdFD = -1;
|
||||
kbdIdx = 0;
|
||||
kbdBufferLen = sizeof(QVFbKeyData) * 5;
|
||||
kbdBuffer = new unsigned char [kbdBufferLen];
|
||||
|
||||
if ((kbdFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
|
||||
qWarning("Cannot open %s (%s)", terminalName.toLatin1().constData(),
|
||||
strerror(errno));
|
||||
} else {
|
||||
// Clear pending input
|
||||
char buf[2];
|
||||
while (QT_READ(kbdFD, buf, 1) > 0) { }
|
||||
|
||||
notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
|
||||
connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
|
||||
}
|
||||
}
|
||||
|
||||
QVFbKeyboardHandler::~QVFbKeyboardHandler()
|
||||
{
|
||||
if (kbdFD >= 0)
|
||||
QT_CLOSE(kbdFD);
|
||||
delete [] kbdBuffer;
|
||||
}
|
||||
|
||||
|
||||
void QVFbKeyboardHandler::readKeyboardData()
|
||||
{
|
||||
int n;
|
||||
do {
|
||||
n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
|
||||
if (n > 0)
|
||||
kbdIdx += n;
|
||||
} while (n > 0);
|
||||
|
||||
int idx = 0;
|
||||
while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) {
|
||||
QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx);
|
||||
if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) {
|
||||
// magic exit key
|
||||
qWarning("Instructed to quit by Virtual Keyboard");
|
||||
qApp->quit();
|
||||
}
|
||||
QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat);
|
||||
idx += sizeof(QVFbKeyData);
|
||||
}
|
||||
|
||||
int surplus = kbdIdx - idx;
|
||||
for (int i = 0; i < surplus; i++)
|
||||
kbdBuffer[i] = kbdBuffer[idx+i];
|
||||
kbdIdx = surplus;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_KBD_QVFB
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKBDVFB_QWS_H
|
||||
#define QKBDVFB_QWS_H
|
||||
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
|
||||
#ifndef QT_NO_QWS_KBD_QVFB
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
class QVFbKeyboardHandler : public QObject, public QWSKeyboardHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVFbKeyboardHandler(const QString &device);
|
||||
virtual ~QVFbKeyboardHandler();
|
||||
|
||||
private Q_SLOTS:
|
||||
void readKeyboardData();
|
||||
|
||||
private:
|
||||
QString terminalName;
|
||||
int kbdFD;
|
||||
int kbdIdx;
|
||||
int kbdBufferLen;
|
||||
unsigned char *kbdBuffer;
|
||||
QSocketNotifier *notifier;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_KBD_QVFB
|
||||
|
||||
#endif // QT_NO_QWS_KEYBOARD
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QKBDVFB_QWS_H
|
@ -1,653 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmouse_qws.h"
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qscreen_qws.h"
|
||||
#include "qapplication.h"
|
||||
#include "qtextstream.h"
|
||||
#include "qfile.h"
|
||||
#include "qdebug.h"
|
||||
#include "qscreen_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QWSPointerCalibrationData
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSPointerCalibrationData class is a container for
|
||||
mouse calibration data in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QWSPointerCalibrationData stores device and screen coordinates in
|
||||
the devPoints and screenPoints variables, respectively.
|
||||
|
||||
A calibration program should create a QWSPointerCalibrationData
|
||||
object, fill the devPoints and screenPoints variables with its
|
||||
device and screen coordinates, and pass the object to the mouse
|
||||
driver using the QWSMouseHandler::calibrate() function.
|
||||
|
||||
\sa QWSCalibratedMouseHandler, {Mouse Calibration Example}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QWSPointerCalibrationData::devPoints
|
||||
\brief the raw device coordinates for each value of the Location enum.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\variable QWSPointerCalibrationData::screenPoints
|
||||
\brief the logical screen coordinates for each value of the Location enum.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QWSPointerCalibrationData::Location
|
||||
|
||||
This enum describes the various logical positions that can be
|
||||
specified by the devPoints and screenPoints variables.
|
||||
|
||||
\value TopLeft Index of the top left corner of the screen.
|
||||
\value BottomLeft Index of the bottom left corner of the screen.
|
||||
\value BottomRight Index of the bottom right corner of the screen.
|
||||
\value TopRight Index of the top right corner of the screen.
|
||||
\value Center Index of the center of the screen.
|
||||
\value LastLocation Last index in the pointer arrays.
|
||||
*/
|
||||
|
||||
class QWSMouseHandlerPrivate
|
||||
{
|
||||
public:
|
||||
QWSMouseHandlerPrivate() : screen(qt_screen) {}
|
||||
|
||||
const QScreen *screen;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QWSMouseHandler
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSMouseHandler class is a base class for mouse drivers in
|
||||
Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several mouse
|
||||
protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
|
||||
handling} documentation for details. Custom mouse drivers can be
|
||||
implemented by subclassing the QWSMouseHandler class and creating
|
||||
a mouse driver plugin (derived from QMouseDriverPlugin).
|
||||
The default implementation of the QMouseDriverFactory class
|
||||
will automatically detect the plugin, and load the driver into the
|
||||
server application at run-time using Qt's \l {How to Create Qt
|
||||
Plugins}{plugin system}.
|
||||
|
||||
The mouse driver receives mouse events from the system device and
|
||||
encapsulates each event with an instance of the QWSEvent class
|
||||
which it then passes to the server application (the server is
|
||||
responsible for propagating the event to the appropriate
|
||||
client). To receive mouse events, a QWSMouseHandler object will
|
||||
usually create a QSocketNotifier object for the given device. The
|
||||
QSocketNotifier class provides support for monitoring activity on
|
||||
a file descriptor. When the socket notifier receives data, it will
|
||||
call the mouse driver's mouseChanged() function to send the event
|
||||
to the \l{Qt for Embedded Linux} server application for relaying to
|
||||
clients.
|
||||
|
||||
If you are creating a driver for a device that needs calibration
|
||||
or noise reduction, such as a touchscreen, use the
|
||||
QWSCalibratedMouseHandler subclass instead to take advantage of
|
||||
the calibrate() and clearCalibration() functions. The \l
|
||||
{qws/mousecalibration}{Mouse Calibration}
|
||||
demonstrates how to write a simple program using the mechanisms
|
||||
provided by the QWSMouseHandler class to calibrate a mouse driver.
|
||||
|
||||
Note that when deriving from the QWSMouseHandler class, the
|
||||
resume() and suspend() functions must be reimplemented to control
|
||||
the flow of mouse input, i.e., the default implementation does
|
||||
nothing. Reimplementations of these functions typically call the
|
||||
QSocketNotifier::setEnabled() function to enable or disable the
|
||||
socket notifier, respectively.
|
||||
|
||||
In addition, QWSMouseHandler provides the setScreen() function
|
||||
that allows you to specify a screen for your mouse driver and the
|
||||
limitToScreen() function that ensures that a given position is
|
||||
within this screen's boundaries (changing the position if
|
||||
necessary). Finally, QWSMouseHandler provides the pos() function
|
||||
returning the current mouse position.
|
||||
|
||||
\sa QMouseDriverPlugin, QMouseDriverFactory, {Qt for Embedded Linux Pointer
|
||||
Handling}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QWSMouseHandler::suspend()
|
||||
|
||||
Implement this function to suspend reading and handling of mouse
|
||||
events, e.g., call the QSocketNotifier::setEnabled() function to
|
||||
disable the socket notifier.
|
||||
|
||||
\sa resume()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QWSMouseHandler::resume()
|
||||
|
||||
Implement this function to resume reading and handling mouse
|
||||
events, e.g., call the QSocketNotifier::setEnabled() function to
|
||||
enable the socket notifier.
|
||||
|
||||
\sa suspend()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QPoint &QWSMouseHandler::pos() const
|
||||
|
||||
Returns the current mouse position.
|
||||
|
||||
\sa mouseChanged(), limitToScreen()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a mouse driver. The \a driver and \a device arguments
|
||||
are passed by the QWS_MOUSE_PROTO environment variable.
|
||||
|
||||
Call the QWSServer::setMouseHandler() function to make the newly
|
||||
created mouse driver, the primary driver. Note that the primary
|
||||
driver is controlled by the system, i.e., the system will delete
|
||||
it upon exit.
|
||||
*/
|
||||
QWSMouseHandler::QWSMouseHandler(const QString &, const QString &)
|
||||
: mousePos(QWSServer::mousePosition), d_ptr(new QWSMouseHandlerPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this mouse driver.
|
||||
|
||||
Do not call this function if this driver is the primary mouse
|
||||
driver, i.e., if QWSServer::setMouseHandler() function has been
|
||||
called passing this driver as argument. The primary mouse
|
||||
driver is deleted by the system.
|
||||
*/
|
||||
QWSMouseHandler::~QWSMouseHandler()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
Ensures that the given \a position is within the screen's
|
||||
boundaries, changing the \a position if necessary.
|
||||
|
||||
\sa pos(), setScreen()
|
||||
*/
|
||||
|
||||
void QWSMouseHandler::limitToScreen(QPoint &position)
|
||||
{
|
||||
position.setX(qMin(d_ptr->screen->deviceWidth() - 1, qMax(0, position.x())));
|
||||
position.setY(qMin(d_ptr->screen->deviceHeight() - 1, qMax(0, position.y())));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.2
|
||||
|
||||
Sets the screen for this mouse driver to be the given \a screen.
|
||||
|
||||
\sa limitToScreen()
|
||||
*/
|
||||
void QWSMouseHandler::setScreen(const QScreen *screen)
|
||||
{
|
||||
d_ptr->screen = (screen ? screen : qt_screen);
|
||||
}
|
||||
|
||||
/*!
|
||||
Notifies the system of a new mouse event.
|
||||
|
||||
This function updates the current mouse position and sends the
|
||||
event to the \l{Qt for Embedded Linux} server application for
|
||||
delivery to the correct widget. Note that a custom mouse driver must call
|
||||
this function whenever it wants to deliver a new mouse event.
|
||||
|
||||
The given \a position is the global position of the mouse cursor.
|
||||
The \a state parameter is a bitmask of the Qt::MouseButton enum's
|
||||
values, indicating which mouse buttons are pressed. The \a wheel
|
||||
parameter is the delta value of the mouse wheel as returned by
|
||||
QWheelEvent::delta().
|
||||
|
||||
\sa pos()
|
||||
*/
|
||||
void QWSMouseHandler::mouseChanged(const QPoint &position, int state, int wheel)
|
||||
{
|
||||
mousePos = position + d_ptr->screen->offset();
|
||||
QWSServer::sendMouseEvent(mousePos, state, wheel);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QWSMouseHandler::clearCalibration()
|
||||
|
||||
This virtual function allows subclasses of QWSMouseHandler to
|
||||
clear the calibration information. Note that the default
|
||||
implementation does nothing.
|
||||
|
||||
\sa QWSCalibratedMouseHandler::clearCalibration(), calibrate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWSMouseHandler::calibrate(const QWSPointerCalibrationData *data)
|
||||
|
||||
This virtual function allows subclasses of QWSMouseHandler to set
|
||||
the calibration information passed in the given \a data. Note that
|
||||
the default implementation does nothing.
|
||||
|
||||
\sa QWSCalibratedMouseHandler::calibrate(), clearCalibration()
|
||||
*/
|
||||
|
||||
/*! \fn QWSMouseHandler::getCalibration(QWSPointerCalibrationData *data) const
|
||||
This virtual function allows subclasses of QWSMouseHandler
|
||||
to fill in the device coordinates in \a data with values
|
||||
that correspond to screen coordinates that are already in
|
||||
\a data. Note that the default implementation does nothing.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QWSCalibratedMouseHandler
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSCalibratedMouseHandler class provides mouse
|
||||
calibration and noise reduction in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several mouse
|
||||
protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
|
||||
handling} documentation for details. In general, custom mouse
|
||||
drivers can be implemented by subclassing the QWSMouseHandler
|
||||
class. But when the system device does not have a fixed mapping
|
||||
between device and screen coordinates and/or produces noisy events
|
||||
(e.g., a touchscreen), you should derive from the
|
||||
QWSCalibratedMouseHandler class instead to take advantage of its
|
||||
calibration functionality. As always, you must also create a mouse
|
||||
driver plugin (derived from QMouseDriverPlugin);
|
||||
the implementation of the QMouseDriverFactory class will then
|
||||
automatically detect the plugin, and load the driver into the
|
||||
server application at run-time using Qt's
|
||||
\l{How to Create Qt Plugins}{plugin system}.
|
||||
|
||||
QWSCalibratedMouseHandler provides an implementation of the
|
||||
calibrate() function to update the calibration parameters based on
|
||||
coordinate mapping of the given calibration data. The calibration
|
||||
data is represented by an QWSPointerCalibrationData object. The
|
||||
linear transformation between device coordinates and screen
|
||||
coordinates is performed by calling the transform() function
|
||||
explicitly on the points passed to the
|
||||
QWSMouseHandler::mouseChanged() function. Use the
|
||||
clearCalibration() function to make the mouse driver return mouse
|
||||
events in raw device coordinates and not in screen coordinates.
|
||||
|
||||
The calibration parameters are recalculated whenever calibrate()
|
||||
is called, and they can be stored using the writeCalibration()
|
||||
function. Previously written parameters can be retrieved at any
|
||||
time using the readCalibration() function (calibration parameters
|
||||
are always read when the class is instantiated). Note that the
|
||||
calibration parameters is written to and read from the file
|
||||
currently specified by the POINTERCAL_FILE environment variable;
|
||||
the default file is \c /etc/pointercal.
|
||||
|
||||
To achieve noise reduction, QWSCalibratedMouseHandler provides the
|
||||
sendFiltered() function. Use this function instead of
|
||||
mouseChanged() whenever a mouse event occurs. The filter's size
|
||||
can be manipulated using the setFilterSize() function.
|
||||
|
||||
\sa QWSMouseHandler, QWSPointerCalibrationData,
|
||||
{Mouse Calibration Example}
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
||||
QWSCalibratedMouseHandler::QWSCalibratedMouseHandler(const QString &, const QString &)
|
||||
: samples(5), currSample(0), numSamples(0)
|
||||
{
|
||||
clearCalibration();
|
||||
readCalibration();
|
||||
}
|
||||
|
||||
/*!
|
||||
Fills \a cd with the device coordinates corresponding to the given
|
||||
screen coordinates.
|
||||
|
||||
\internal
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::getCalibration(QWSPointerCalibrationData *cd) const
|
||||
{
|
||||
const qint64 scale = qint64(a) * qint64(e) - qint64(b) * qint64(d);
|
||||
const qint64 xOff = qint64(b) * qint64(f) - qint64(c) * qint64(e);
|
||||
const qint64 yOff = qint64(c) * qint64(d) - qint64(a) * qint64(f);
|
||||
for (int i = 0; i <= QWSPointerCalibrationData::LastLocation; ++i) {
|
||||
const qint64 sX = cd->screenPoints[i].x();
|
||||
const qint64 sY = cd->screenPoints[i].y();
|
||||
const qint64 dX = (s*(e*sX - b*sY) + xOff) / scale;
|
||||
const qint64 dY = (s*(a*sY - d*sX) + yOff) / scale;
|
||||
cd->devPoints[i] = QPoint(dX, dY);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Clears the current calibration, i.e., makes the mouse
|
||||
driver return mouse events in raw device coordinates instead of
|
||||
screen coordinates.
|
||||
|
||||
\sa calibrate()
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::clearCalibration()
|
||||
{
|
||||
a = 1;
|
||||
b = 0;
|
||||
c = 0;
|
||||
d = 0;
|
||||
e = 1;
|
||||
f = 0;
|
||||
s = 1;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Saves the current calibration parameters in \c /etc/pointercal
|
||||
(separated by whitespace and in alphabetical order).
|
||||
|
||||
You can override the default \c /etc/pointercal by specifying
|
||||
another file using the POINTERCAL_FILE environment variable.
|
||||
|
||||
\sa readCalibration()
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::writeCalibration()
|
||||
{
|
||||
QString calFile;
|
||||
calFile = QString::fromLocal8Bit(qgetenv("POINTERCAL_FILE"));
|
||||
if (calFile.isEmpty())
|
||||
calFile = QLatin1String("/etc/pointercal");
|
||||
|
||||
#ifndef QT_NO_TEXTSTREAM
|
||||
QFile file(calFile);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QTextStream t(&file);
|
||||
t << a << ' ' << b << ' ' << c << ' ';
|
||||
t << d << ' ' << e << ' ' << f << ' ' << s << endl;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
qCritical("QWSCalibratedMouseHandler::writeCalibration: "
|
||||
"Could not save calibration into %s", qPrintable(calFile));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads previously written calibration parameters which are stored
|
||||
in \c /etc/pointercal (separated by whitespace and in alphabetical
|
||||
order).
|
||||
|
||||
You can override the default \c /etc/pointercal by specifying
|
||||
another file using the POINTERCAL_FILE environment variable.
|
||||
|
||||
|
||||
\sa writeCalibration()
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::readCalibration()
|
||||
{
|
||||
QString calFile = QString::fromLocal8Bit(qgetenv("POINTERCAL_FILE"));
|
||||
if (calFile.isEmpty())
|
||||
calFile = QLatin1String("/etc/pointercal");
|
||||
|
||||
#ifndef QT_NO_TEXTSTREAM
|
||||
QFile file(calFile);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QTextStream t(&file);
|
||||
t >> a >> b >> c >> d >> e >> f >> s;
|
||||
if (s == 0 || t.status() != QTextStream::Ok) {
|
||||
qCritical("Corrupt calibration data");
|
||||
clearCalibration();
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
qDebug() << "Could not read calibration:" <<calFile;
|
||||
}
|
||||
}
|
||||
|
||||
static int ilog2(quint32 n)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (n & 0xffff0000) {
|
||||
n >>= 16;
|
||||
result += 16;
|
||||
}
|
||||
if (n & 0xff00) {
|
||||
n >>= 8;
|
||||
result += 8;}
|
||||
if (n & 0xf0) {
|
||||
n >>= 4;
|
||||
result += 4;
|
||||
}
|
||||
if (n & 0xc) {
|
||||
n >>= 2;
|
||||
result += 2;
|
||||
}
|
||||
if (n & 0x2)
|
||||
result += 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
Updates the calibration parameters based on coordinate mapping of
|
||||
the given \a data.
|
||||
|
||||
Create an instance of the QWSPointerCalibrationData class, fill in
|
||||
the device and screen coordinates and pass that object to the mouse
|
||||
driver using this function.
|
||||
|
||||
\sa clearCalibration(), transform()
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::calibrate(const QWSPointerCalibrationData *data)
|
||||
{
|
||||
// Algorithm derived from
|
||||
// "How To Calibrate Touch Screens" by Carlos E. Vidales,
|
||||
// printed in Embedded Systems Programming, Vol. 15 no 6, June 2002
|
||||
// URL: http://www.embedded.com/showArticle.jhtml?articleID=9900629
|
||||
|
||||
const QPoint pd0 = data->devPoints[QWSPointerCalibrationData::TopLeft];
|
||||
const QPoint pd1 = data->devPoints[QWSPointerCalibrationData::TopRight];
|
||||
const QPoint pd2 = data->devPoints[QWSPointerCalibrationData::BottomRight];
|
||||
const QPoint p0 = data->screenPoints[QWSPointerCalibrationData::TopLeft];
|
||||
const QPoint p1 = data->screenPoints[QWSPointerCalibrationData::TopRight];
|
||||
const QPoint p2 = data->screenPoints[QWSPointerCalibrationData::BottomRight];
|
||||
|
||||
const qint64 xd0 = pd0.x();
|
||||
const qint64 xd1 = pd1.x();
|
||||
const qint64 xd2 = pd2.x();
|
||||
const qint64 yd0 = pd0.y();
|
||||
const qint64 yd1 = pd1.y();
|
||||
const qint64 yd2 = pd2.y();
|
||||
const qint64 x0 = p0.x();
|
||||
const qint64 x1 = p1.x();
|
||||
const qint64 x2 = p2.x();
|
||||
const qint64 y0 = p0.y();
|
||||
const qint64 y1 = p1.y();
|
||||
const qint64 y2 = p2.y();
|
||||
|
||||
qint64 scale = ((xd0 - xd2)*(yd1 - yd2) - (xd1 - xd2)*(yd0 - yd2));
|
||||
int shift = 0;
|
||||
qint64 absScale = qAbs(scale);
|
||||
// use maximum 16 bit precision to reduce risk of integer overflow
|
||||
if (absScale > (1 << 16)) {
|
||||
shift = ilog2(absScale >> 16) + 1;
|
||||
scale >>= shift;
|
||||
}
|
||||
|
||||
s = scale;
|
||||
a = ((x0 - x2)*(yd1 - yd2) - (x1 - x2)*(yd0 - yd2)) >> shift;
|
||||
b = ((xd0 - xd2)*(x1 - x2) - (x0 - x2)*(xd1 - xd2)) >> shift;
|
||||
c = (yd0*(xd2*x1 - xd1*x2) + yd1*(xd0*x2 - xd2*x0) + yd2*(xd1*x0 - xd0*x1)) >> shift;
|
||||
d = ((y0 - y2)*(yd1 - yd2) - (y1 - y2)*(yd0 - yd2)) >> shift;
|
||||
e = ((xd0 - xd2)*(y1 - y2) - (y0 - y2)*(xd1 - xd2)) >> shift;
|
||||
f = (yd0*(xd2*y1 - xd1*y2) + yd1*(xd0*y2 - xd2*y0) + yd2*(xd1*y0 - xd0*y1)) >> shift;
|
||||
|
||||
writeCalibration();
|
||||
}
|
||||
|
||||
/*!
|
||||
Transforms the given \a position from device coordinates to screen
|
||||
coordinates, and returns the transformed position.
|
||||
|
||||
This function is typically called explicitly on the points passed
|
||||
to the QWSMouseHandler::mouseChanged() function.
|
||||
|
||||
This implementation is a linear transformation using 7 parameters
|
||||
(\c a, \c b, \c c, \c d, \c e, \c f and \c s) to transform the
|
||||
device coordinates (\c Xd, \c Yd) into screen coordinates (\c Xs,
|
||||
\c Ys) using the following equations:
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp 0
|
||||
|
||||
\sa mouseChanged()
|
||||
*/
|
||||
QPoint QWSCalibratedMouseHandler::transform(const QPoint &position)
|
||||
{
|
||||
QPoint tp;
|
||||
|
||||
tp.setX((a * position.x() + b * position.y() + c) / s);
|
||||
tp.setY((d * position.x() + e * position.y() + f) / s);
|
||||
|
||||
return tp;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the size of the filter used in noise reduction to the given
|
||||
\a size.
|
||||
|
||||
The sendFiltered() function reduces noice by calculating an
|
||||
average position from a collection of mouse event positions. The
|
||||
filter size determines the number of positions that forms the
|
||||
basis for these calculations.
|
||||
|
||||
\sa sendFiltered()
|
||||
*/
|
||||
void QWSCalibratedMouseHandler::setFilterSize(int size)
|
||||
{
|
||||
samples.resize(qMax(1, size));
|
||||
numSamples = 0;
|
||||
currSample = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QWSCalibratedMouseHandler::sendFiltered(const QPoint &position, int state)
|
||||
|
||||
Notifies the system of a new mouse event \e after applying a noise
|
||||
reduction filter. Returns true if the filtering process is
|
||||
successful; otherwise returns false. Note that if the filtering
|
||||
process failes, the system is not notified about the event.
|
||||
|
||||
The given \a position is the global position of the mouse. The \a
|
||||
state parameter is a bitmask of the Qt::MouseButton enum's values
|
||||
indicating which mouse buttons are pressed.
|
||||
|
||||
The noice is reduced by calculating an average position from a
|
||||
collection of mouse event positions and then calling the
|
||||
mouseChanged() function with the new position. The number of
|
||||
positions that is used is determined by the filter size.
|
||||
|
||||
\sa mouseChanged(), setFilterSize()
|
||||
*/
|
||||
bool QWSCalibratedMouseHandler::sendFiltered(const QPoint &position, int button)
|
||||
{
|
||||
if (!button) {
|
||||
if (numSamples >= samples.count())
|
||||
mouseChanged(transform(position), 0);
|
||||
currSample = 0;
|
||||
numSamples = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sent = false;
|
||||
samples[currSample] = position;
|
||||
numSamples++;
|
||||
if (numSamples >= samples.count()) {
|
||||
|
||||
int ignore = -1;
|
||||
if (samples.count() > 2) { // throw away the "worst" sample
|
||||
int maxd = 0;
|
||||
for (int i = 0; i < samples.count(); i++) {
|
||||
int d = (mousePos - samples[i]).manhattanLength();
|
||||
if (d > maxd) {
|
||||
maxd = d;
|
||||
ignore = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// average the rest
|
||||
QPoint pos(0, 0);
|
||||
int numAveraged = 0;
|
||||
for (int i = 0; i < samples.count(); i++) {
|
||||
if (ignore == i)
|
||||
continue;
|
||||
pos += samples[i];
|
||||
++numAveraged;
|
||||
}
|
||||
if (numAveraged)
|
||||
pos /= numAveraged;
|
||||
|
||||
mouseChanged(transform(pos), button);
|
||||
sent = true;
|
||||
}
|
||||
currSample++;
|
||||
if (currSample >= samples.count())
|
||||
currSample = 0;
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSE_QWS_H
|
||||
#define QMOUSE_QWS_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qpolygon.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QWSMouseHandlerPrivate;
|
||||
class QScreen;
|
||||
|
||||
class Q_GUI_EXPORT QWSPointerCalibrationData
|
||||
{
|
||||
public:
|
||||
enum Location { TopLeft = 0, BottomLeft = 1, BottomRight = 2, TopRight = 3,
|
||||
Center = 4, LastLocation = Center };
|
||||
QPoint devPoints[5];
|
||||
QPoint screenPoints[5];
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QWSMouseHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
virtual ~QWSMouseHandler();
|
||||
|
||||
virtual void clearCalibration() {}
|
||||
virtual void calibrate(const QWSPointerCalibrationData *) {}
|
||||
virtual void getCalibration(QWSPointerCalibrationData *) const {}
|
||||
|
||||
virtual void resume() = 0;
|
||||
virtual void suspend() = 0;
|
||||
|
||||
void limitToScreen(QPoint &pt);
|
||||
void mouseChanged(const QPoint& pos, int bstate, int wheel = 0);
|
||||
const QPoint &pos() const { return mousePos; }
|
||||
|
||||
void setScreen(const QScreen *screen);
|
||||
|
||||
protected:
|
||||
QPoint &mousePos;
|
||||
QWSMouseHandlerPrivate *d_ptr;
|
||||
};
|
||||
|
||||
|
||||
class Q_GUI_EXPORT QWSCalibratedMouseHandler : public QWSMouseHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSCalibratedMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
|
||||
virtual void clearCalibration();
|
||||
virtual void calibrate(const QWSPointerCalibrationData *);
|
||||
virtual void getCalibration(QWSPointerCalibrationData *) const;
|
||||
|
||||
protected:
|
||||
bool sendFiltered(const QPoint &, int button);
|
||||
QPoint transform(const QPoint &);
|
||||
|
||||
void readCalibration();
|
||||
void writeCalibration();
|
||||
void setFilterSize(int);
|
||||
|
||||
private:
|
||||
int a, b, c;
|
||||
int d, e, f;
|
||||
int s;
|
||||
QPolygon samples;
|
||||
int currSample;
|
||||
int numSamples;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSE_QWS_H
|
@ -1,197 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmousedriverfactory_qws.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qmousepc_qws.h"
|
||||
#include "qmouselinuxtp_qws.h"
|
||||
#include "qmouselinuxinput_qws.h"
|
||||
#include "qmousevfb_qws.h"
|
||||
#include "qmousetslib_qws.h"
|
||||
#include "qmouseqnx_qws.h"
|
||||
#include "qmouseintegrity_qws.h"
|
||||
#include <stdlib.h>
|
||||
#include "private/qfactoryloader_p.h"
|
||||
#include "qmousedriverplugin_qws.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QWSMouseHandlerFactoryInterface_iid,
|
||||
QLatin1String("/mousedrivers"), Qt::CaseInsensitive))
|
||||
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
|
||||
/*!
|
||||
\class QMouseDriverFactory
|
||||
\ingroup qws
|
||||
|
||||
\brief The QMouseDriverFactory class creates mouse drivers in
|
||||
Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QMouseDriverFactory is used to detect and instantiate the
|
||||
available mouse drivers, allowing \l{Qt for Embedded Linux} to load the
|
||||
preferred driver into the server application at runtime. The
|
||||
create() function returns a QWSMouseHandler object representing
|
||||
the mouse driver identified by a given key. The valid keys
|
||||
(i.e. the supported drivers) can be retrieved using the keys()
|
||||
function.
|
||||
|
||||
\l{Qt for Embedded Linux} provides several built-in mouse drivers. In
|
||||
addition, custom mouse drivers can be added using Qt's plugin
|
||||
mechanism, i.e. by subclassing the QWSMouseHandler class and
|
||||
creating a mouse driver plugin (QMouseDriverPlugin). See the
|
||||
\l{Qt for Embedded Linux Pointer Handling}{pointer handling}
|
||||
documentation for details.
|
||||
|
||||
\sa QWSMouseHandler, QMouseDriverPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Creates the mouse driver specified by the given \a key, using the
|
||||
display specified by the given \a device.
|
||||
|
||||
Note that the keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &device)
|
||||
{
|
||||
QString driver = key.toLower();
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
|
||||
if (driver == QLatin1String("qnx") || driver.isEmpty())
|
||||
return new QQnxMouseHandler(key, device);
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_MOUSE_INTEGRITY)
|
||||
if (driver == QLatin1String("integrity") || driver.isEmpty())
|
||||
return new QIntMouseHandler(key, device);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXTP
|
||||
if (driver == QLatin1String("linuxtp") || driver.isEmpty())
|
||||
return new QWSLinuxTPMouseHandler(key, device);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_PC
|
||||
if (driver == QLatin1String("auto")
|
||||
|| driver == QLatin1String("intellimouse")
|
||||
|| driver == QLatin1String("microsoft")
|
||||
|| driver == QLatin1String("mousesystems")
|
||||
|| driver == QLatin1String("mouseman")
|
||||
|| driver.isEmpty()) {
|
||||
return new QWSPcMouseHandler(key, device);
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_TSLIB
|
||||
if (driver == QLatin1String("tslib") || driver.isEmpty())
|
||||
return new QWSTslibMouseHandler(key, device);
|
||||
#endif
|
||||
# ifndef QT_NO_QWS_MOUSE_LINUXINPUT
|
||||
if (driver == QLatin1String("linuxinput") || \
|
||||
driver == QLatin1String("usb") || \
|
||||
driver == QLatin1String("linuxis"))
|
||||
return new QWSLinuxInputMouseHandler(device);
|
||||
# endif
|
||||
#ifndef QT_NO_QWS_MOUSE_QVFB
|
||||
if (driver == QLatin1String("qvfbmouse") || driver == QLatin1String("qvfb"))
|
||||
return new QVFbMouseHandler(key, device);
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
if (QWSMouseHandlerFactoryInterface *factory = qobject_cast<QWSMouseHandlerFactoryInterface*>(loader()->instance(driver)))
|
||||
return factory->create(driver, device);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of valid keys, i.e. the available mouse drivers.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
QStringList QMouseDriverFactory::keys()
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
|
||||
list << QLatin1String("QNX");
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_MOUSE_INTEGRITY)
|
||||
list << QLatin1String("INTEGRITY");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXTP
|
||||
list << QLatin1String("LinuxTP");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_PC
|
||||
list << QLatin1String("Auto")
|
||||
<< QLatin1String("IntelliMouse")
|
||||
<< QLatin1String("Microsoft")
|
||||
<< QLatin1String("MouseSystems")
|
||||
<< QLatin1String("MouseMan");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_TSLIB
|
||||
list << QLatin1String("Tslib");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
|
||||
list << QLatin1String("LinuxInput");
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
QStringList plugins = loader()->keys();
|
||||
for (int i = 0; i < plugins.size(); ++i) {
|
||||
if (!list.contains(plugins.at(i)))
|
||||
list += plugins.at(i);
|
||||
}
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
return list;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,67 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEDRIVERFACTORY_QWS_H
|
||||
#define QMOUSEDRIVERFACTORY_QWS_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QString;
|
||||
class QWSMouseHandler;
|
||||
|
||||
class Q_GUI_EXPORT QMouseDriverFactory
|
||||
{
|
||||
public:
|
||||
static QStringList keys();
|
||||
static QWSMouseHandler *create(const QString&, const QString &);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSEDRIVERFACTORY_QWS_H
|
@ -1,124 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmousedriverplugin_qws.h"
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
#include "qmouse_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMouseDriverPlugin
|
||||
\ingroup plugins
|
||||
\ingroup qws
|
||||
|
||||
\brief The QMouseDriverPlugin class is an abstract base class for
|
||||
mouse driver plugins in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several mouse
|
||||
protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
|
||||
handling} documentation for details. Custom mouse drivers can be
|
||||
implemented by subclassing the QWSMouseHandler class and creating
|
||||
a mouse driver plugin.
|
||||
|
||||
A mouse driver plugin can be created by subclassing
|
||||
QMouseDriverPlugin and reimplementing the pure virtual keys() and
|
||||
create() functions. By exporting the derived class using the
|
||||
Q_EXPORT_PLUGIN2() macro, The default implementation of the
|
||||
QMouseDriverFactory class will automatically detect the plugin and
|
||||
load the driver into the server application at run-time. See \l
|
||||
{How to Create Qt Plugins} for details.
|
||||
|
||||
\sa QWSMouseHandler, QMouseDriverFactory
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QMouseDriverPlugin::keys() const
|
||||
|
||||
Implement this function to return the list of valid keys, i.e. the
|
||||
mouse drivers supported by this plugin.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several mouse
|
||||
protocols, see the \l {Qt for Embedded Linux Pointer Handling}{pointer
|
||||
handling} documentation for details.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a mouse driver plugin with the given \a parent.
|
||||
|
||||
Note that this constructor is invoked automatically by the
|
||||
Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
|
||||
explicitly.
|
||||
*/
|
||||
QMouseDriverPlugin::QMouseDriverPlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the mouse driver plugin.
|
||||
|
||||
Note that Qt destroys a plugin automatically when it is no longer
|
||||
used, so there is no need for calling the destructor explicitly.
|
||||
*/
|
||||
QMouseDriverPlugin::~QMouseDriverPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QScreen* QMouseDriverPlugin::create(const QString &key, const QString& device)
|
||||
|
||||
Implement this function to create a driver matching the type
|
||||
specified by the given \a key and \a device parameters. Note that
|
||||
keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEDRIVERPLUGIN_QWS_H
|
||||
#define QMOUSEDRIVERPLUGIN_QWS_H
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
class QWSMouseHandler;
|
||||
|
||||
struct Q_GUI_EXPORT QWSMouseHandlerFactoryInterface : public QFactoryInterface
|
||||
{
|
||||
virtual QWSMouseHandler* create(const QString &name, const QString &device) = 0;
|
||||
};
|
||||
|
||||
#define QWSMouseHandlerFactoryInterface_iid "com.trolltech.Qt.QWSMouseHandlerFactoryInterface"
|
||||
Q_DECLARE_INTERFACE(QWSMouseHandlerFactoryInterface, QWSMouseHandlerFactoryInterface_iid)
|
||||
|
||||
class Q_GUI_EXPORT QMouseDriverPlugin : public QObject, public QWSMouseHandlerFactoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QWSMouseHandlerFactoryInterface:QFactoryInterface)
|
||||
public:
|
||||
explicit QMouseDriverPlugin(QObject *parent = 0);
|
||||
~QMouseDriverPlugin();
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QWSMouseHandler* create(const QString& driver, const QString &device) = 0;
|
||||
};
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSEDRIVERPLUGIN_QWS_H
|
@ -1,271 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_INTEGRITY
|
||||
|
||||
#include "qmouseintegrity_qws.h"
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qapplication.h>
|
||||
#include <qtimer.h>
|
||||
#include <qthread.h>
|
||||
|
||||
#include <INTEGRITY.h>
|
||||
|
||||
|
||||
typedef Address MOUSEHandler;
|
||||
typedef struct MOUSEMessageStruct
|
||||
{
|
||||
Value x;
|
||||
Value y;
|
||||
Value z;
|
||||
Value buttons;
|
||||
} MOUSEMessage;
|
||||
|
||||
static Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute);
|
||||
static Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
|
||||
Boolean absolute);
|
||||
static Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIntMouseListenThread;
|
||||
|
||||
class QIntMousePrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class QIntMouseListenTaskThread;
|
||||
Q_SIGNALS:
|
||||
void mouseDataAvailable(int x, int y, int buttons);
|
||||
public:
|
||||
QIntMousePrivate(QIntMouseHandler *handler);
|
||||
~QIntMousePrivate();
|
||||
void dataReady(int x, int y, int buttons) { emit mouseDataAvailable(x, y, buttons); }
|
||||
bool calibrated;
|
||||
bool waitforread;
|
||||
bool suspended;
|
||||
QIntMouseListenThread *mousethread;
|
||||
|
||||
private:
|
||||
QIntMouseHandler *handler;
|
||||
};
|
||||
|
||||
class QIntMouseListenThread : public QThread
|
||||
{
|
||||
protected:
|
||||
QIntMousePrivate *imp;
|
||||
bool loop;
|
||||
public:
|
||||
QIntMouseListenThread(QIntMousePrivate *im) : QThread(), imp(im) {};
|
||||
~QIntMouseListenThread() {};
|
||||
void run();
|
||||
void stoploop() { loop = false; };
|
||||
};
|
||||
|
||||
|
||||
QIntMouseHandler::QIntMouseHandler(const QString &driver, const QString &device)
|
||||
: QObject(), QWSCalibratedMouseHandler(driver, device)
|
||||
{
|
||||
QPoint test(1,1);
|
||||
d = new QIntMousePrivate(this);
|
||||
connect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
|
||||
|
||||
d->calibrated = (test != transform(test));
|
||||
|
||||
d->mousethread->start();
|
||||
}
|
||||
|
||||
QIntMouseHandler::~QIntMouseHandler()
|
||||
{
|
||||
disconnect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QIntMouseHandler::resume()
|
||||
{
|
||||
d->suspended = true;
|
||||
}
|
||||
|
||||
void QIntMouseHandler::suspend()
|
||||
{
|
||||
d->suspended = false;
|
||||
}
|
||||
|
||||
void QIntMouseHandler::readMouseData(int x, int y, int buttons)
|
||||
{
|
||||
d->waitforread = false;
|
||||
if (d->suspended)
|
||||
return;
|
||||
if (d->calibrated) {
|
||||
sendFiltered(QPoint(x, y), buttons);
|
||||
} else {
|
||||
QPoint pos;
|
||||
pos = transform(QPoint(x, y));
|
||||
limitToScreen(pos);
|
||||
mouseChanged(pos, buttons, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void QIntMouseHandler::clearCalibration()
|
||||
{
|
||||
QWSCalibratedMouseHandler::clearCalibration();
|
||||
}
|
||||
|
||||
void QIntMouseHandler::calibrate(const QWSPointerCalibrationData *data)
|
||||
{
|
||||
QWSCalibratedMouseHandler::calibrate(data);
|
||||
}
|
||||
|
||||
void QIntMouseListenThread::run(void)
|
||||
{
|
||||
MOUSEHandler handler;
|
||||
MOUSEMessage msg;
|
||||
Boolean filter;
|
||||
Boolean isabsolute;
|
||||
loop = true;
|
||||
CheckSuccess(MOUSE_Init(&handler, &isabsolute));
|
||||
CheckSuccess(MOUSE_ShouldFilter(handler, &filter));
|
||||
if (!filter)
|
||||
imp->calibrated = false;
|
||||
imp->waitforread = false;
|
||||
do {
|
||||
MOUSE_SynchronousGetPosition(handler, &msg, isabsolute);
|
||||
imp->dataReady(msg.x, msg.y, msg.buttons);
|
||||
} while (loop);
|
||||
QThread::exit(0);
|
||||
}
|
||||
|
||||
QIntMousePrivate::QIntMousePrivate(QIntMouseHandler *handler)
|
||||
: QObject()
|
||||
{
|
||||
this->handler = handler;
|
||||
suspended = false;
|
||||
mousethread = new QIntMouseListenThread(this);
|
||||
}
|
||||
|
||||
QIntMousePrivate::~QIntMousePrivate()
|
||||
{
|
||||
mousethread->stoploop();
|
||||
mousethread->wait();
|
||||
delete mousethread;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmouseintegrity_qws.moc"
|
||||
|
||||
typedef struct USBMouseStruct
|
||||
{
|
||||
Connection mouseconn;
|
||||
Buffer mousemsg[2];
|
||||
Value x;
|
||||
Value y;
|
||||
} USBMouse;
|
||||
|
||||
USBMouse mousedev;
|
||||
|
||||
Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute)
|
||||
{
|
||||
Error E;
|
||||
bool loop = true;
|
||||
memset((void*)&mousedev, 0, sizeof(USBMouse));
|
||||
mousedev.mousemsg[0].BufferType = DataImmediate;
|
||||
mousedev.mousemsg[1].BufferType = DataImmediate | LastBuffer;
|
||||
do {
|
||||
E = RequestResource((Object*)&mousedev.mouseconn,
|
||||
"MouseClient", "!systempassword");
|
||||
if (E == Success) {
|
||||
*isabsolute = true;
|
||||
loop = false;
|
||||
} else {
|
||||
E = RequestResource((Object*)&mousedev.mouseconn,
|
||||
"USBMouseClient", "!systempassword");
|
||||
if (E == Success) {
|
||||
*isabsolute = false;
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
if (loop)
|
||||
sleep(1);
|
||||
} while (loop);
|
||||
*handler = (MOUSEHandler)&mousedev;
|
||||
return Success;
|
||||
}
|
||||
|
||||
Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
|
||||
Boolean isabsolute)
|
||||
{
|
||||
signed long x;
|
||||
signed long y;
|
||||
USBMouse *mdev = (USBMouse *)handler;
|
||||
mdev->mousemsg[0].Transferred = 0;
|
||||
mdev->mousemsg[1].Transferred = 0;
|
||||
SynchronousReceive(mdev->mouseconn, mdev->mousemsg);
|
||||
if (isabsolute) {
|
||||
x = (signed long)mdev->mousemsg[0].Length;
|
||||
y = (signed long)mdev->mousemsg[1].TheAddress;
|
||||
} else {
|
||||
x = mdev->x + (signed long)mdev->mousemsg[0].Length;
|
||||
y = mdev->y + (signed long)mdev->mousemsg[1].TheAddress;
|
||||
}
|
||||
if (x < 0)
|
||||
mdev->x = 0;
|
||||
else
|
||||
mdev->x = x;
|
||||
if (y < 0)
|
||||
mdev->y = 0;
|
||||
else
|
||||
mdev->y = y;
|
||||
msg->x = mdev->x;
|
||||
msg->y = mdev->y;
|
||||
msg->buttons = mdev->mousemsg[0].TheAddress;
|
||||
return Success;
|
||||
}
|
||||
|
||||
Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter)
|
||||
{
|
||||
if (filter == NULL)
|
||||
return Failure;
|
||||
*filter = false;
|
||||
return Success;
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_INTEGRITY
|
||||
|
@ -1,82 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEINTEGRITY_QWS_H
|
||||
#define QMOUSEINTEGRITY_QWS_H
|
||||
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_INTEGRITY
|
||||
|
||||
class QSocketNotifier;
|
||||
class QIntMousePrivate;
|
||||
|
||||
class QIntMouseHandler : public QObject, public QWSCalibratedMouseHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QIntMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
~QIntMouseHandler();
|
||||
|
||||
void resume();
|
||||
void suspend();
|
||||
|
||||
void calibrate(const QWSPointerCalibrationData *data);
|
||||
void clearCalibration();
|
||||
|
||||
private:
|
||||
QIntMousePrivate *d;
|
||||
private Q_SLOTS:
|
||||
void readMouseData(int x, int y, int buttons);
|
||||
};
|
||||
#endif // QT_NO_QWS_MOUSE_INTEGRITY
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSEINTEGRITY_QWS_H
|
@ -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 plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmouselinuxinput_qws.h"
|
||||
|
||||
#include <QScreen>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QWSLinuxInputMousePrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *, const QString &);
|
||||
~QWSLinuxInputMousePrivate();
|
||||
|
||||
void enable(bool on);
|
||||
|
||||
private Q_SLOTS:
|
||||
void readMouseData();
|
||||
|
||||
private:
|
||||
QWSLinuxInputMouseHandler *m_handler;
|
||||
QSocketNotifier * m_notify;
|
||||
int m_fd;
|
||||
int m_x, m_y;
|
||||
int m_buttons;
|
||||
};
|
||||
|
||||
QWSLinuxInputMouseHandler::QWSLinuxInputMouseHandler(const QString &device)
|
||||
: QWSCalibratedMouseHandler(device)
|
||||
{
|
||||
d = new QWSLinuxInputMousePrivate(this, device);
|
||||
}
|
||||
|
||||
QWSLinuxInputMouseHandler::~QWSLinuxInputMouseHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QWSLinuxInputMouseHandler::suspend()
|
||||
{
|
||||
d->enable(false);
|
||||
}
|
||||
|
||||
void QWSLinuxInputMouseHandler::resume()
|
||||
{
|
||||
d->enable(true);
|
||||
}
|
||||
|
||||
QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *h, const QString &device)
|
||||
: m_handler(h), m_notify(0), m_x(0), m_y(0), m_buttons(0)
|
||||
{
|
||||
setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler"));
|
||||
|
||||
QString dev = QLatin1String("/dev/input/event0");
|
||||
if (device.startsWith(QLatin1String("/dev/")))
|
||||
dev = device;
|
||||
|
||||
m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
|
||||
if (m_fd >= 0) {
|
||||
m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
|
||||
connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
|
||||
} else {
|
||||
qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QWSLinuxInputMousePrivate::~QWSLinuxInputMousePrivate()
|
||||
{
|
||||
if (m_fd >= 0)
|
||||
QT_CLOSE(m_fd);
|
||||
}
|
||||
|
||||
void QWSLinuxInputMousePrivate::enable(bool on)
|
||||
{
|
||||
if (m_notify)
|
||||
m_notify->setEnabled(on);
|
||||
}
|
||||
|
||||
void QWSLinuxInputMousePrivate::readMouseData()
|
||||
{
|
||||
if (!qt_screen)
|
||||
return;
|
||||
|
||||
struct ::input_event buffer[32];
|
||||
int n = 0;
|
||||
|
||||
forever {
|
||||
n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
|
||||
|
||||
if (n == 0) {
|
||||
qWarning("Got EOF from the input device.");
|
||||
return;
|
||||
} else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
|
||||
qWarning("Could not read from input device: %s", strerror(errno));
|
||||
return;
|
||||
} else if (n % sizeof(buffer[0]) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
n /= sizeof(buffer[0]);
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
struct ::input_event *data = &buffer[i];
|
||||
|
||||
bool unknown = false;
|
||||
if (data->type == EV_ABS) {
|
||||
if (data->code == ABS_X) {
|
||||
m_x = data->value;
|
||||
} else if (data->code == ABS_Y) {
|
||||
m_y = data->value;
|
||||
} else {
|
||||
unknown = true;
|
||||
}
|
||||
} else if (data->type == EV_REL) {
|
||||
if (data->code == REL_X) {
|
||||
m_x += data->value;
|
||||
} else if (data->code == REL_Y) {
|
||||
m_y += data->value;
|
||||
} else {
|
||||
unknown = true;
|
||||
}
|
||||
} else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
|
||||
m_buttons = data->value ? Qt::LeftButton : 0;
|
||||
} else if (data->type == EV_KEY) {
|
||||
int button = 0;
|
||||
switch (data->code) {
|
||||
case BTN_LEFT: button = Qt::LeftButton; break;
|
||||
case BTN_MIDDLE: button = Qt::MidButton; break;
|
||||
case BTN_RIGHT: button = Qt::RightButton; break;
|
||||
}
|
||||
if (data->value)
|
||||
m_buttons |= button;
|
||||
else
|
||||
m_buttons &= ~button;
|
||||
} else if (data->type == EV_SYN && data->code == SYN_REPORT) {
|
||||
QPoint pos(m_x, m_y);
|
||||
pos = m_handler->transform(pos);
|
||||
m_handler->limitToScreen(pos);
|
||||
m_handler->mouseChanged(pos, m_buttons);
|
||||
} else if (data->type == EV_MSC && data->code == MSC_SCAN) {
|
||||
// kernel encountered an unmapped key - just ignore it
|
||||
continue;
|
||||
} else {
|
||||
unknown = true;
|
||||
}
|
||||
if (unknown) {
|
||||
qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmouselinuxinput_qws.moc"
|
@ -1,78 +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 plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSELINUXINPUT_QWS_H
|
||||
#define QMOUSELINUXINPUT_QWS_H
|
||||
|
||||
#include <QtGui/QWSCalibratedMouseHandler>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
|
||||
|
||||
class QWSLinuxInputMousePrivate;
|
||||
|
||||
class QWSLinuxInputMouseHandler : public QWSCalibratedMouseHandler
|
||||
{
|
||||
public:
|
||||
QWSLinuxInputMouseHandler(const QString &);
|
||||
~QWSLinuxInputMouseHandler();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
private:
|
||||
QWSLinuxInputMousePrivate *d;
|
||||
|
||||
friend class QWSLinuxInputMousePrivate;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_LINUXINPUT
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSELINUXINPUT_QWS_H
|
@ -1,335 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmouselinuxtp_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXTP
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qsocketnotifier.h"
|
||||
#include "qtimer.h"
|
||||
#include "qapplication.h"
|
||||
#include "qscreen_qws.h"
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(QT_QWS_IPAQ)
|
||||
#define QT_QWS_IPAQ_RAW
|
||||
#define QT_QWS_SCREEN_COORDINATES
|
||||
typedef struct {
|
||||
unsigned short pressure;
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
unsigned short pad;
|
||||
} TS_EVENT;
|
||||
#elif defined(QT_QWS_EBX)
|
||||
#define QT_QWS_EBX_RAW
|
||||
#define QT_QWS_SCREEN_COORDINATES
|
||||
#ifndef QT_QWS_SHARP
|
||||
typedef struct {
|
||||
unsigned short pressure;
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
unsigned short pad;
|
||||
} TS_EVENT;
|
||||
#else
|
||||
typedef struct {
|
||||
long y;
|
||||
long x;
|
||||
long pressure;
|
||||
long long millisecs;
|
||||
} TS_EVENT;
|
||||
#define QT_QWS_TP_SAMPLE_SIZE 10
|
||||
#define QT_QWS_TP_MINIMUM_SAMPLES 4
|
||||
#define QT_QWS_TP_PRESSURE_THRESHOLD 500
|
||||
#define QT_QWS_TP_MOVE_LIMIT 50
|
||||
#define QT_QWS_TP_JITTER_LIMIT 2
|
||||
#endif
|
||||
#else // not IPAQ, not SHARP
|
||||
typedef struct {
|
||||
unsigned short pressure;
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
unsigned short pad;
|
||||
} TS_EVENT;
|
||||
#endif
|
||||
|
||||
#ifndef QT_QWS_TP_SAMPLE_SIZE
|
||||
#define QT_QWS_TP_SAMPLE_SIZE 5
|
||||
#endif
|
||||
|
||||
#ifndef QT_QWS_TP_MINIMUM_SAMPLES
|
||||
#define QT_QWS_TP_MINIMUM_SAMPLES 5
|
||||
#endif
|
||||
|
||||
#ifndef QT_QWS_TP_PRESSURE_THRESHOLD
|
||||
#define QT_QWS_TP_PRESSURE_THRESHOLD 1
|
||||
#endif
|
||||
|
||||
#ifndef QT_QWS_TP_MOVE_LIMIT
|
||||
#define QT_QWS_TP_MOVE_LIMIT 100
|
||||
#endif
|
||||
|
||||
#ifndef QT_QWS_TP_JITTER_LIMIT
|
||||
#define QT_QWS_TP_JITTER_LIMIT 2
|
||||
#endif
|
||||
|
||||
class QWSLinuxTPMouseHandlerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHandler *h, const QString &);
|
||||
~QWSLinuxTPMouseHandlerPrivate();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
private:
|
||||
static const int mouseBufSize = 2048;
|
||||
int mouseFD;
|
||||
QPoint oldmouse;
|
||||
QPoint oldTotalMousePos;
|
||||
bool waspressed;
|
||||
QPolygon samples;
|
||||
int currSample;
|
||||
int lastSample;
|
||||
int numSamples;
|
||||
int skipCount;
|
||||
int mouseIdx;
|
||||
uchar mouseBuf[mouseBufSize];
|
||||
QWSLinuxTPMouseHandler *handler;
|
||||
QSocketNotifier *mouseNotifier;
|
||||
|
||||
private slots:
|
||||
void readMouseData();
|
||||
};
|
||||
|
||||
QWSLinuxTPMouseHandler::QWSLinuxTPMouseHandler(const QString &driver, const QString &device)
|
||||
: QWSCalibratedMouseHandler(driver, device)
|
||||
{
|
||||
d = new QWSLinuxTPMouseHandlerPrivate(this, device);
|
||||
}
|
||||
|
||||
QWSLinuxTPMouseHandler::~QWSLinuxTPMouseHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QWSLinuxTPMouseHandler::suspend()
|
||||
{
|
||||
d->suspend();
|
||||
}
|
||||
|
||||
void QWSLinuxTPMouseHandler::resume()
|
||||
{
|
||||
d->resume();
|
||||
}
|
||||
|
||||
QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHandler *h,
|
||||
const QString &device)
|
||||
: samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
|
||||
numSamples(0), skipCount(0), handler(h)
|
||||
{
|
||||
QString mousedev;
|
||||
if (device.isEmpty()) {
|
||||
#if defined(QT_QWS_IPAQ)
|
||||
# ifdef QT_QWS_IPAQ_RAW
|
||||
mousedev = QLatin1String("/dev/h3600_tsraw");
|
||||
# else
|
||||
mousedev = QLatin1String("/dev/h3600_ts");
|
||||
# endif
|
||||
#else
|
||||
mousedev = QLatin1String("/dev/ts");
|
||||
#endif
|
||||
} else {
|
||||
mousedev = device;
|
||||
}
|
||||
if ((mouseFD = QT_OPEN(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
|
||||
qWarning("Cannot open %s (%s)", qPrintable(mousedev), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read,
|
||||
this);
|
||||
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
|
||||
waspressed=false;
|
||||
mouseIdx = 0;
|
||||
}
|
||||
|
||||
QWSLinuxTPMouseHandlerPrivate::~QWSLinuxTPMouseHandlerPrivate()
|
||||
{
|
||||
if (mouseFD >= 0)
|
||||
QT_CLOSE(mouseFD);
|
||||
}
|
||||
|
||||
void QWSLinuxTPMouseHandlerPrivate::suspend()
|
||||
{
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(false);
|
||||
}
|
||||
|
||||
void QWSLinuxTPMouseHandlerPrivate::resume()
|
||||
{
|
||||
mouseIdx=0;
|
||||
currSample=0;
|
||||
lastSample=0;
|
||||
numSamples=0;
|
||||
skipCount=0;
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
void QWSLinuxTPMouseHandlerPrivate::readMouseData()
|
||||
{
|
||||
if(!qt_screen)
|
||||
return;
|
||||
|
||||
int n;
|
||||
do {
|
||||
n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
|
||||
if (n > 0)
|
||||
mouseIdx += n;
|
||||
} while (n > 0 && mouseIdx < mouseBufSize);
|
||||
|
||||
//qDebug("readMouseData()");
|
||||
|
||||
TS_EVENT *data;
|
||||
int idx = 0;
|
||||
|
||||
// perhaps we shouldn't be reading EVERY SAMPLE.
|
||||
while (mouseIdx-idx >= (int)sizeof(TS_EVENT)) {
|
||||
uchar *mb = mouseBuf+idx;
|
||||
data = (TS_EVENT *) mb;
|
||||
|
||||
if(data->pressure >= QT_QWS_TP_PRESSURE_THRESHOLD) {
|
||||
#ifdef QT_QWS_SHARP
|
||||
samples[currSample] = QPoint(1000 - data->x, data->y);
|
||||
#else
|
||||
samples[currSample] = QPoint(data->x, data->y);
|
||||
#endif
|
||||
numSamples++;
|
||||
if (numSamples >= QT_QWS_TP_MINIMUM_SAMPLES) {
|
||||
int sampleCount = qMin(numSamples + 1,samples.count());
|
||||
|
||||
// average the rest
|
||||
QPoint mousePos = QPoint(0, 0);
|
||||
QPoint totalMousePos = oldTotalMousePos;
|
||||
totalMousePos += samples[currSample];
|
||||
if(numSamples >= samples.count())
|
||||
totalMousePos -= samples[lastSample];
|
||||
|
||||
mousePos = totalMousePos / (sampleCount - 1);
|
||||
#if defined(QT_QWS_SCREEN_COORDINATES)
|
||||
mousePos = handler->transform(mousePos);
|
||||
#endif
|
||||
if(!waspressed)
|
||||
oldmouse = mousePos;
|
||||
QPoint dp = mousePos - oldmouse;
|
||||
int dxSqr = dp.x() * dp.x();
|
||||
int dySqr = dp.y() * dp.y();
|
||||
if (dxSqr + dySqr < (QT_QWS_TP_MOVE_LIMIT * QT_QWS_TP_MOVE_LIMIT)) {
|
||||
if (waspressed) {
|
||||
if ((dxSqr + dySqr > (QT_QWS_TP_JITTER_LIMIT * QT_QWS_TP_JITTER_LIMIT)) || skipCount > 2) {
|
||||
handler->mouseChanged(mousePos,Qt::LeftButton);
|
||||
oldmouse = mousePos;
|
||||
skipCount = 0;
|
||||
} else {
|
||||
skipCount++;
|
||||
}
|
||||
} else {
|
||||
handler->mouseChanged(mousePos,Qt::LeftButton);
|
||||
oldmouse=mousePos;
|
||||
waspressed=true;
|
||||
}
|
||||
|
||||
// save recuring information
|
||||
currSample++;
|
||||
if (numSamples >= samples.count())
|
||||
lastSample++;
|
||||
oldTotalMousePos = totalMousePos;
|
||||
} else {
|
||||
numSamples--; // don't use this sample, it was bad.
|
||||
}
|
||||
} else {
|
||||
// build up the average
|
||||
oldTotalMousePos += samples[currSample];
|
||||
currSample++;
|
||||
}
|
||||
if (currSample >= samples.count())
|
||||
currSample = 0;
|
||||
if (lastSample >= samples.count())
|
||||
lastSample = 0;
|
||||
} else {
|
||||
currSample = 0;
|
||||
lastSample = 0;
|
||||
numSamples = 0;
|
||||
skipCount = 0;
|
||||
oldTotalMousePos = QPoint(0,0);
|
||||
if (waspressed) {
|
||||
handler->mouseChanged(oldmouse,0);
|
||||
oldmouse = QPoint(-100, -100);
|
||||
waspressed=false;
|
||||
}
|
||||
}
|
||||
idx += sizeof(TS_EVENT);
|
||||
}
|
||||
|
||||
int surplus = mouseIdx - idx;
|
||||
for (int i = 0; i < surplus; i++)
|
||||
mouseBuf[i] = mouseBuf[idx+i];
|
||||
mouseIdx = surplus;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmouselinuxtp_qws.moc"
|
||||
|
||||
#endif //QT_NO_QWS_MOUSE_LINUXTP
|
@ -1,77 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSELINUXTP_QWS_H
|
||||
#define QMOUSELINUXTP_QWS_H
|
||||
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_LINUXTP
|
||||
|
||||
class QWSLinuxTPMouseHandlerPrivate;
|
||||
|
||||
class QWSLinuxTPMouseHandler : public QWSCalibratedMouseHandler
|
||||
{
|
||||
friend class QWSLinuxTPMouseHandlerPrivate;
|
||||
public:
|
||||
explicit QWSLinuxTPMouseHandler(const QString & = QString(),
|
||||
const QString & = QString());
|
||||
~QWSLinuxTPMouseHandler();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
protected:
|
||||
QWSLinuxTPMouseHandlerPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_LINUXTP
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSELINUXTP_QWS_H
|
@ -1,794 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmousepc_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_PC
|
||||
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qsocketnotifier.h"
|
||||
#include "qwsevent_qws.h"
|
||||
#include "qwscommand_qws_p.h"
|
||||
#include "qwsutils_qws.h"
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qpolygon.h"
|
||||
#include "qtimer.h"
|
||||
#include "qfile.h"
|
||||
#include "qtextstream.h"
|
||||
#include "qstringlist.h"
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <qscreen_qws.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
//#define QWS_MOUSE_DEBUG
|
||||
|
||||
/*
|
||||
* Automatic-detection mouse driver
|
||||
*/
|
||||
|
||||
class QWSPcMouseSubHandler {
|
||||
protected:
|
||||
enum { max_buf=32 };
|
||||
|
||||
int fd;
|
||||
|
||||
uchar buffer[max_buf];
|
||||
int nbuf;
|
||||
|
||||
QPoint motion;
|
||||
int bstate;
|
||||
int wheel;
|
||||
|
||||
int goodness;
|
||||
int badness;
|
||||
|
||||
virtual int tryData()=0;
|
||||
|
||||
public:
|
||||
QWSPcMouseSubHandler(int f) : fd(f)
|
||||
{
|
||||
initState();
|
||||
}
|
||||
virtual ~QWSPcMouseSubHandler() {}
|
||||
|
||||
int file() const { return fd; }
|
||||
|
||||
void closeIfNot(int& f)
|
||||
{
|
||||
if (fd != f) {
|
||||
f = fd;
|
||||
QT_CLOSE(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void initState() { nbuf = bstate = goodness = badness = 0; }
|
||||
|
||||
void worse(int by=1) { badness+=by; }
|
||||
bool reliable() const { return goodness >= 5 && badness < 50; }
|
||||
int buttonState() const { return bstate; }
|
||||
bool motionPending() const { return motion!=QPoint(0,0); }
|
||||
QPoint takeMotion() { QPoint r=motion; motion=QPoint(0,0); return r; }
|
||||
int takeWheel() { int result = wheel; wheel = 0; return result; }
|
||||
|
||||
void appendData(uchar* data, int length)
|
||||
{
|
||||
memcpy(buffer+nbuf, data, length);
|
||||
nbuf += length;
|
||||
}
|
||||
|
||||
enum UsageResult { Insufficient, Motion, Button };
|
||||
|
||||
UsageResult useData()
|
||||
{
|
||||
int pbstate = bstate;
|
||||
int n = tryData();
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
if (n) {
|
||||
fprintf(stderr, "QWSPcMouseSubHandler tryData read %d bytes:", n);
|
||||
for (int i=0; i<n; ++i)
|
||||
fprintf(stderr, " %02x", buffer[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
if (n > 0) {
|
||||
if (n<nbuf)
|
||||
memmove(buffer, buffer+n, nbuf-n);
|
||||
nbuf -= n;
|
||||
return (wheel || pbstate != bstate) ? Button : Motion;
|
||||
}
|
||||
return Insufficient;
|
||||
}
|
||||
};
|
||||
|
||||
class QWSPcMouseSubHandler_intellimouse : public QWSPcMouseSubHandler {
|
||||
int packetsize;
|
||||
public:
|
||||
QWSPcMouseSubHandler_intellimouse(int f) : QWSPcMouseSubHandler(f)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
int n;
|
||||
uchar reply[20];
|
||||
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_intellimouse: pre-init tcflush");
|
||||
#endif
|
||||
}
|
||||
static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
|
||||
static const uchar query[] = { 0xf2 };
|
||||
if (QT_WRITE(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
|
||||
badness = 100;
|
||||
return;
|
||||
}
|
||||
usleep(10000);
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_intellimouse: post-init tcflush");
|
||||
#endif
|
||||
}
|
||||
if (QT_WRITE(fd, query, sizeof(query))!=sizeof(query)) {
|
||||
badness = 100;
|
||||
return;
|
||||
}
|
||||
usleep(10000);
|
||||
n = QT_READ(fd, reply, 20);
|
||||
if (n > 0) {
|
||||
goodness = 10;
|
||||
switch (reply[n-1]) {
|
||||
case 3:
|
||||
case 4:
|
||||
packetsize = 4;
|
||||
break;
|
||||
default:
|
||||
packetsize = 3;
|
||||
}
|
||||
} else {
|
||||
badness = 100;
|
||||
}
|
||||
}
|
||||
|
||||
int tryData()
|
||||
{
|
||||
if (nbuf >= packetsize) {
|
||||
//int overflow = (buffer[0]>>6)& 0x03;
|
||||
|
||||
if (/*overflow ||*/ !(buffer[0] & 8)) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
qDebug("Intellimouse: skipping (overflow)");
|
||||
#endif
|
||||
badness++;
|
||||
return 1;
|
||||
} else {
|
||||
QPoint delta((buffer[0] & 0x10) ? buffer[1]-256 : buffer[1],
|
||||
(buffer[0] & 0x20) ? 256-buffer[2] : -buffer[2]);
|
||||
motion += delta;
|
||||
int nbstate = buffer[0] & 0x7;
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
int debugwheel =
|
||||
#endif
|
||||
wheel = packetsize > 3 ? -(signed char)buffer[3] : 0;
|
||||
if (wheel < -2 || wheel > 2)
|
||||
wheel = 0;
|
||||
wheel *= 120; // WHEEL_DELTA?
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
qDebug("Intellimouse: motion %d,%d, state %d, raw wheel %d, wheel %d", motion.x(), motion.y(), nbstate, debugwheel, wheel);
|
||||
#endif
|
||||
if (motion.x() || motion.y() || bstate != nbstate || wheel) {
|
||||
bstate = nbstate;
|
||||
goodness++;
|
||||
} else {
|
||||
badness++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return packetsize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class QWSPcMouseSubHandler_mouseman : public QWSPcMouseSubHandler {
|
||||
int packetsize;
|
||||
public:
|
||||
QWSPcMouseSubHandler_mouseman(int f) : QWSPcMouseSubHandler(f)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_mouseman: initial tcflush");
|
||||
#endif
|
||||
}
|
||||
QT_WRITE(fd,"",1);
|
||||
usleep(50000);
|
||||
QT_WRITE(fd,"@EeI!",5);
|
||||
usleep(10000);
|
||||
static const char ibuf[] = { 246, 244 };
|
||||
QT_WRITE(fd,ibuf,1);
|
||||
QT_WRITE(fd,ibuf+1,1);
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_mouseman: tcflush");
|
||||
#endif
|
||||
}
|
||||
usleep(10000);
|
||||
|
||||
char buf[100];
|
||||
while (QT_READ(fd, buf, 100) > 0) { } // eat unwanted replies
|
||||
}
|
||||
|
||||
int tryData()
|
||||
{
|
||||
if (nbuf >= 3) {
|
||||
int nbstate = 0;
|
||||
if (buffer[0] & 0x01)
|
||||
nbstate |= Qt::LeftButton;
|
||||
if (buffer[0] & 0x02)
|
||||
nbstate |= Qt::RightButton;
|
||||
if (buffer[0] & 0x04)
|
||||
nbstate |= Qt::MidButton;
|
||||
|
||||
int overflow = (buffer[0]>>6)& 0x03;
|
||||
if (overflow) {
|
||||
//### wheel events signalled with overflow bit, ignore for now
|
||||
badness++;
|
||||
return 1;
|
||||
} else {
|
||||
bool xs = buffer[0] & 0x10;
|
||||
bool ys = buffer[0] & 0x20;
|
||||
int dx = xs ? buffer[1]-256 : buffer[1];
|
||||
int dy = ys ? buffer[2]-256 : buffer[2];
|
||||
|
||||
motion += QPoint(dx, -dy);
|
||||
if (motion.x() || motion.y() || bstate != nbstate) {
|
||||
bstate = nbstate;
|
||||
goodness++;
|
||||
} else {
|
||||
badness++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class QWSPcMouseSubHandler_serial : public QWSPcMouseSubHandler {
|
||||
public:
|
||||
QWSPcMouseSubHandler_serial(int f) : QWSPcMouseSubHandler(f)
|
||||
{
|
||||
initSerial();
|
||||
}
|
||||
|
||||
protected:
|
||||
void setflags(int f)
|
||||
{
|
||||
termios tty;
|
||||
if (tcgetattr(fd, &tty) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_serial: tcgetattr");
|
||||
#endif
|
||||
}
|
||||
tty.c_iflag = IGNBRK | IGNPAR;
|
||||
tty.c_oflag = 0;
|
||||
tty.c_lflag = 0;
|
||||
tty.c_cflag = f | CREAD | CLOCAL | HUPCL;
|
||||
#ifdef Q_OS_LINUX
|
||||
tty.c_line = 0;
|
||||
#endif
|
||||
tty.c_cc[VTIME] = 0;
|
||||
tty.c_cc[VMIN] = 1;
|
||||
if (tcsetattr(fd, TCSANOW, &tty) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_serial: tcgetattr");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void initSerial()
|
||||
{
|
||||
int speed[4] = { B9600, B4800, B2400, B1200 };
|
||||
|
||||
for (int n = 0; n < 4; n++) {
|
||||
setflags(CSTOPB | speed[n]);
|
||||
QT_WRITE(fd, "*q", 2);
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class QWSPcMouseSubHandler_mousesystems : public QWSPcMouseSubHandler_serial {
|
||||
public:
|
||||
// ##### This driver has not been tested
|
||||
|
||||
QWSPcMouseSubHandler_mousesystems(int f) : QWSPcMouseSubHandler_serial(f)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
setflags(B1200|CS8|CSTOPB);
|
||||
// 60Hz
|
||||
if (QT_WRITE(fd, "R", 1)!=1) {
|
||||
badness = 100;
|
||||
return;
|
||||
}
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QT_QWS_VNC_DEBUG
|
||||
perror("QWSPcMouseSubHandler_mousesystems: tcflush");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int tryData()
|
||||
{
|
||||
if (nbuf >= 5) {
|
||||
if ((buffer[0] & 0xf8) != 0x80) {
|
||||
badness++;
|
||||
return 1;
|
||||
}
|
||||
motion +=
|
||||
QPoint((signed char)buffer[1] + (signed char)buffer[3],
|
||||
-(signed char)buffer[2] + (signed char)buffer[4]);
|
||||
int t = ~buffer[0];
|
||||
int nbstate = ((t&3) << 1) | ((t&4) >> 2);
|
||||
if (motion.x() || motion.y() || bstate != nbstate) {
|
||||
bstate = nbstate;
|
||||
goodness++;
|
||||
} else {
|
||||
badness++;
|
||||
return 1;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class QWSPcMouseSubHandler_ms : public QWSPcMouseSubHandler_serial {
|
||||
int mman;
|
||||
public:
|
||||
QWSPcMouseSubHandler_ms(int f) : QWSPcMouseSubHandler_serial(f)
|
||||
{
|
||||
mman=0;
|
||||
init();
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
setflags(B1200|CS7);
|
||||
// 60Hz
|
||||
if (QT_WRITE(fd, "R", 1)!=1) {
|
||||
badness = 100;
|
||||
return;
|
||||
}
|
||||
if (tcflush(fd,TCIOFLUSH) == -1) {
|
||||
#ifdef QWS_MOUSE_DEBUG
|
||||
perror("QWSPcMouseSubHandler_ms: tcflush");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int tryData()
|
||||
{
|
||||
if (!(buffer[0] & 0x40)) {
|
||||
if (buffer[0] == 0x20 && (bstate & Qt::MidButton)) {
|
||||
mman=1; // mouseman extension
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int extra = mman&&(bstate & Qt::MidButton);
|
||||
if (nbuf >= 3+extra) {
|
||||
int nbstate = 0;
|
||||
if (buffer[0] == 0x40 && !bstate && !buffer[1] && !buffer[2]) {
|
||||
nbstate = Qt::MidButton;
|
||||
} else {
|
||||
nbstate = ((buffer[0] & 0x20) >> 5)
|
||||
| ((buffer[0] & 0x10) >> 3);
|
||||
if (extra && buffer[3] == 0x20)
|
||||
nbstate = Qt::MidButton;
|
||||
}
|
||||
|
||||
if (buffer[1] & 0x40) {
|
||||
badness++;
|
||||
return 1;
|
||||
} else {
|
||||
motion +=
|
||||
QPoint((signed char)((buffer[0]&0x3)<<6)
|
||||
|(signed char)(buffer[1]&0x3f),
|
||||
(signed char)((buffer[0]&0xc)<<4)
|
||||
|(signed char)(buffer[2]&0x3f));
|
||||
if (motion.x() || motion.y() || bstate != nbstate) {
|
||||
bstate = nbstate;
|
||||
goodness++;
|
||||
} else {
|
||||
badness++;
|
||||
return 1;
|
||||
}
|
||||
return 3+extra;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
|
||||
class QWSPcMouseHandlerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSPcMouseHandlerPrivate(QWSPcMouseHandler *h, const QString &, const QString &);
|
||||
~QWSPcMouseHandlerPrivate();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
private:
|
||||
enum { max_dev=32 };
|
||||
QWSPcMouseSubHandler *sub[max_dev];
|
||||
QList<QSocketNotifier*> notifiers;
|
||||
int nsub;
|
||||
int retries;
|
||||
|
||||
private slots:
|
||||
void readMouseData(int);
|
||||
|
||||
private:
|
||||
void openDevices();
|
||||
void closeDevices();
|
||||
void notify(int fd);
|
||||
bool sendEvent(QWSPcMouseSubHandler& h);
|
||||
|
||||
private:
|
||||
QWSPcMouseHandler *handler;
|
||||
QString driver;
|
||||
QString device;
|
||||
qreal accel;
|
||||
int accel_limit;
|
||||
};
|
||||
|
||||
QWSPcMouseHandler::QWSPcMouseHandler(const QString &driver, const QString &device)
|
||||
: QWSMouseHandler(driver, device)
|
||||
{
|
||||
d = new QWSPcMouseHandlerPrivate(this, driver, device);
|
||||
}
|
||||
|
||||
QWSPcMouseHandler::~QWSPcMouseHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QWSPcMouseHandler::suspend()
|
||||
{
|
||||
d->suspend();
|
||||
}
|
||||
|
||||
void QWSPcMouseHandler::resume()
|
||||
{
|
||||
d->resume();
|
||||
}
|
||||
|
||||
|
||||
QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate(QWSPcMouseHandler *h,
|
||||
const QString &drv, const QString &arg)
|
||||
: handler(h), driver(drv)
|
||||
{
|
||||
QStringList args = arg.split(QLatin1Char(':'), QString::SkipEmptyParts);
|
||||
|
||||
int index;
|
||||
|
||||
accel = qreal(2.0);
|
||||
QRegExp accelRegex(QLatin1String("^accel=(\\d+\\.?\\d*)$"));
|
||||
index = args.indexOf(accelRegex);
|
||||
if (index >= 0) {
|
||||
accel = qreal(accelRegex.cap(1).toDouble());
|
||||
args.removeAt(index);
|
||||
}
|
||||
|
||||
accel_limit = 5;
|
||||
QRegExp accelLimitRegex(QLatin1String("^accel_limit=(\\d+)$"));
|
||||
index = args.indexOf(accelLimitRegex);
|
||||
if (index >= 0) {
|
||||
accel_limit = accelLimitRegex.cap(1).toInt();
|
||||
args.removeAt(index);
|
||||
}
|
||||
|
||||
device = args.join(QString());
|
||||
|
||||
retries = 0;
|
||||
openDevices();
|
||||
}
|
||||
|
||||
QWSPcMouseHandlerPrivate::~QWSPcMouseHandlerPrivate()
|
||||
{
|
||||
closeDevices();
|
||||
}
|
||||
|
||||
/*
|
||||
QWSPcMouseHandler::UsageResult QWSPcMouseHandler::useDev(Dev& d)
|
||||
{
|
||||
if (d.nbuf >= mouseData[d.protocol].bytesPerPacket) {
|
||||
uchar *mb = d.buf;
|
||||
int bstate = 0;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
|
||||
switch (mouseProtocol) {
|
||||
case MouseMan:
|
||||
case IntelliMouse:
|
||||
{
|
||||
bstate = mb[0] & 0x7; // assuming Qt::*Button order
|
||||
|
||||
int overflow = (mb[0]>>6)& 0x03;
|
||||
if (mouseProtocol == MouseMan && overflow) {
|
||||
//### wheel events signalled with overflow bit, ignore for now
|
||||
}
|
||||
else {
|
||||
bool xs = mb[0] & 0x10;
|
||||
bool ys = mb[0] & 0x20;
|
||||
dx = xs ? mb[1]-256 : mb[1];
|
||||
dy = ys ? mb[2]-256 : mb[2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Microsoft:
|
||||
if (((mb[0] & 0x20) >> 3)) {
|
||||
bstate |= Qt::LeftButton;
|
||||
}
|
||||
if (((mb[0] & 0x10) >> 4)) {
|
||||
bstate |= Qt::RightButton;
|
||||
}
|
||||
|
||||
dx=(signed char)(((mb[0] & 0x03) << 6) | (mb[1] & 0x3f));
|
||||
dy=-(signed char)(((mb[0] & 0x0c) << 4) | (mb[2] & 0x3f));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bool QWSPcMouseHandlerPrivate::sendEvent(QWSPcMouseSubHandler& h)
|
||||
{
|
||||
if (h.reliable()) {
|
||||
QPoint motion = h.takeMotion();
|
||||
if (qAbs(motion.x()) > accel_limit || qAbs(motion.y()) > accel_limit)
|
||||
motion *= accel;
|
||||
QPoint newPos = handler->pos() + motion;
|
||||
if (qt_screen->isTransformed()) {
|
||||
QSize s = QSize(qt_screen->width(), qt_screen->height());
|
||||
newPos = qt_screen->mapToDevice(newPos, s);
|
||||
}
|
||||
handler->limitToScreen(newPos);
|
||||
|
||||
handler->mouseChanged(newPos, h.buttonState(), h.takeWheel());
|
||||
return true;
|
||||
} else {
|
||||
h.takeMotion();
|
||||
if (h.buttonState() & (Qt::RightButton|Qt::MidButton)) {
|
||||
// Strange for the user to press right or middle without
|
||||
// a moving mouse!
|
||||
h.worse();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void QWSPcMouseHandlerPrivate::openDevices()
|
||||
{
|
||||
nsub=0;
|
||||
int fd = -1;
|
||||
|
||||
QString drv = driver.toLower();
|
||||
if (!drv.isEmpty() && drv != QLatin1String("auto")) {
|
||||
// Manually specified mouse
|
||||
QByteArray dev = device.toLatin1();
|
||||
if (drv == QLatin1String("intellimouse")) {
|
||||
if (dev.isEmpty())
|
||||
dev = "/dev/psaux";
|
||||
fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
|
||||
if (fd >= 0)
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
|
||||
} else if (drv == QLatin1String("microsoft")) {
|
||||
if (dev.isEmpty())
|
||||
dev = "/dev/ttyS0";
|
||||
fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
|
||||
if (fd >= 0)
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
|
||||
} else if (drv == QLatin1String("mousesystems")) {
|
||||
if (dev.isEmpty())
|
||||
dev = "/dev/ttyS0";
|
||||
fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
|
||||
if (fd >= 0)
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
|
||||
} else if (drv == QLatin1String("mouseman")) {
|
||||
if (dev.isEmpty())
|
||||
dev = "/dev/psaux";
|
||||
fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
|
||||
if (fd >= 0)
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_mouseman(fd);
|
||||
}
|
||||
if (fd >= 0)
|
||||
notify(fd);
|
||||
else
|
||||
qCritical("Error opening mouse device '%s': %s",
|
||||
dev.constData(), strerror(errno));
|
||||
} else {
|
||||
// Try automatically
|
||||
fd = QT_OPEN("/dev/psaux", O_RDWR | O_NDELAY);
|
||||
if (fd >= 0) {
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
|
||||
notify(fd);
|
||||
}
|
||||
fd = QT_OPEN("/dev/input/mice", O_RDWR | O_NDELAY);
|
||||
if (fd >= 0) {
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
|
||||
notify(fd);
|
||||
//qDebug("/dev/input/mice fd %d #%d", fd, nsub-1);
|
||||
}
|
||||
|
||||
// include the code below to auto-detect serial mice, and to mess up
|
||||
// any sort of serial communication
|
||||
#if 0
|
||||
const char fn[4][11] = { "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3" };
|
||||
for (int ch = 0; ch < 4; ++ch) {
|
||||
fd = QT_OPEN(fn[ch], O_RDWR | O_NDELAY);
|
||||
if (fd >= 0) {
|
||||
//sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
|
||||
sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
|
||||
notify(fd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void QWSPcMouseHandlerPrivate::closeDevices()
|
||||
{
|
||||
int pfd=-1;
|
||||
for (int i=0; i<nsub; i++) {
|
||||
sub[i]->closeIfNot(pfd);
|
||||
delete sub[i];
|
||||
}
|
||||
qDeleteAll(notifiers);
|
||||
notifiers.clear();
|
||||
}
|
||||
|
||||
void QWSPcMouseHandlerPrivate::suspend()
|
||||
{
|
||||
for (int i=0; i<notifiers.size(); ++i)
|
||||
notifiers.at(i)->setEnabled(false);
|
||||
}
|
||||
|
||||
void QWSPcMouseHandlerPrivate::resume()
|
||||
{
|
||||
for (int i=0; i<nsub; i++)
|
||||
sub[i]->initState();
|
||||
|
||||
for (int i=0; i<notifiers.size(); ++i)
|
||||
notifiers.at(i)->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QWSPcMouseHandlerPrivate::notify(int fd)
|
||||
{
|
||||
QSocketNotifier *mouseNotifier
|
||||
= new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
||||
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData(int)));
|
||||
notifiers.append(mouseNotifier);
|
||||
}
|
||||
|
||||
void QWSPcMouseHandlerPrivate::readMouseData(int fd)
|
||||
{
|
||||
for (;;) {
|
||||
uchar buf[8];
|
||||
int n = read(fd, buf, 8);
|
||||
if (n<=0)
|
||||
break;
|
||||
for (int i=0; i<nsub; i++) {
|
||||
QWSPcMouseSubHandler& h = *sub[i];
|
||||
if (h.file() == fd) {
|
||||
h.appendData(buf,n);
|
||||
for (;;) {
|
||||
switch (h.useData()) {
|
||||
case QWSPcMouseSubHandler::Button:
|
||||
sendEvent(h);
|
||||
break;
|
||||
case QWSPcMouseSubHandler::Insufficient:
|
||||
goto breakbreak;
|
||||
case QWSPcMouseSubHandler::Motion:
|
||||
break;
|
||||
}
|
||||
}
|
||||
breakbreak:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool any_reliable=false;
|
||||
for (int i=0; i<nsub; i++) {
|
||||
QWSPcMouseSubHandler& h = *sub[i];
|
||||
if (h.motionPending())
|
||||
sendEvent(h);
|
||||
any_reliable = any_reliable || h.reliable();
|
||||
}
|
||||
if (any_reliable) {
|
||||
// ... get rid of all unreliable ones? All bad ones?
|
||||
} else if (retries < 2) {
|
||||
// Try again - maybe the mouse was being moved when we tried to init.
|
||||
closeDevices();
|
||||
openDevices();
|
||||
retries++;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmousepc_qws.moc"
|
||||
|
||||
#endif // QT_NO_MOUSE_PC
|
@ -1,76 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEPC_QWS_H
|
||||
#define QMOUSEPC_QWS_H
|
||||
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_PC
|
||||
|
||||
class QWSPcMouseHandlerPrivate;
|
||||
|
||||
class QWSPcMouseHandler : public QWSMouseHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSPcMouseHandler(const QString & = QString(),
|
||||
const QString & = QString());
|
||||
~QWSPcMouseHandler();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
protected:
|
||||
QWSPcMouseHandlerPrivate *d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_PC
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSEPC_QWS_H
|
@ -1,190 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
#include "qmouseqnx_qws.h"
|
||||
|
||||
#include "qsocketnotifier.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#include <sys/dcmd_input.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QQnxMouseHandler
|
||||
\preliminary
|
||||
\ingroup qws
|
||||
\internal
|
||||
\since 4.6
|
||||
|
||||
\brief The QQnxMouseHandler class implements a mouse driver
|
||||
for the QNX \c{devi-hid} input manager.
|
||||
|
||||
To be able to compile this mouse handler, \l{Qt for Embedded Linux}
|
||||
must be configured with the \c -qt-mouse-qnx option, see the
|
||||
\l{Qt for Embedded Linux Pointer Handling}{Pointer Handling} documentation for details.
|
||||
|
||||
In order to use this mouse handler, the \c{devi-hid} input manager
|
||||
must be set up and run with the resource manager interface (option \c{-r}).
|
||||
Also, Photon must not be running.
|
||||
|
||||
Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
|
||||
Note that after running \c{devi-hid}, you will not be able to use the local
|
||||
shell anymore. It is suggested to run the command in a shell scrip, that launches
|
||||
a Qt application after invocation of \c{devi-hid}.
|
||||
|
||||
To make \l{Qt for Embedded Linux} explicitly choose the qnx mouse
|
||||
handler, set the QWS_MOUSE_PROTO environment variable to \c{qnx}. By default,
|
||||
the first mouse device (\c{/dev/devi/mouse0}) is used. To override, pass a device
|
||||
name as the first and only parameter, for example
|
||||
\c{QWS_MOUSE_PROTO=qnx:/dev/devi/mouse1; export QWS_MOUSE_PROTO}.
|
||||
|
||||
\sa {Qt for Embedded Linux Pointer Handling}{Pointer Handling}, {Qt for Embedded Linux}
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a mouse handler for the specified \a device, defaulting to \c{/dev/devi/mouse0}.
|
||||
The \a driver parameter must be \c{"qnx"}.
|
||||
|
||||
Note that you should never instanciate this class, instead let QMouseDriverFactory
|
||||
handle the mouse handlers.
|
||||
|
||||
\sa QMouseDriverFactory
|
||||
*/
|
||||
QQnxMouseHandler::QQnxMouseHandler(const QString & /*driver*/, const QString &device)
|
||||
{
|
||||
// open the mouse device with O_NONBLOCK so reading won't block when there's no data
|
||||
mouseFD = QT_OPEN(device.isEmpty() ? "/dev/devi/mouse0" : device.toLatin1().constData(),
|
||||
QT_OPEN_RDONLY | O_NONBLOCK);
|
||||
if (mouseFD == -1) {
|
||||
qErrnoWarning(errno, "QQnxMouseHandler: Unable to open mouse device");
|
||||
return;
|
||||
}
|
||||
|
||||
// register a socket notifier on the file descriptor so we'll wake up whenever
|
||||
// there's a mouse move waiting for us.
|
||||
mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
|
||||
connect(mouseNotifier, SIGNAL(activated(int)), SLOT(socketActivated()));
|
||||
|
||||
qDebug() << "QQnxMouseHandler: connected.";
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this mouse handler and closes the connection to the mouse device.
|
||||
*/
|
||||
QQnxMouseHandler::~QQnxMouseHandler()
|
||||
{
|
||||
QT_CLOSE(mouseFD);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
void QQnxMouseHandler::resume()
|
||||
{
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(true);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
void QQnxMouseHandler::suspend()
|
||||
{
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(false);
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
|
||||
This function is called whenever there is activity on the mouse device.
|
||||
By default, it reads up to 10 mouse move packets and calls mouseChanged()
|
||||
for each of them.
|
||||
*/
|
||||
void QQnxMouseHandler::socketActivated()
|
||||
{
|
||||
// _mouse_packet is a QNX structure. devi-hid is nice enough to translate
|
||||
// the raw byte data from mouse devices into generic format for us.
|
||||
_mouse_packet packet;
|
||||
|
||||
int iteration = 0;
|
||||
|
||||
// read mouse events in batches of 10. Since we're getting quite a lot
|
||||
// of mouse events, it's better to do them in batches than to return to the
|
||||
// event loop every time.
|
||||
do {
|
||||
int bytesRead = QT_READ(mouseFD, &packet, sizeof(packet));
|
||||
if (bytesRead == -1) {
|
||||
// EAGAIN means that there are no more mouse events to read
|
||||
if (errno != EAGAIN)
|
||||
qErrnoWarning(errno, "QQnxMouseHandler: Unable to read from socket");
|
||||
return;
|
||||
}
|
||||
|
||||
// bytes read should always be equal to the size of a packet.
|
||||
Q_ASSERT(bytesRead == sizeof(packet));
|
||||
|
||||
// translate the coordinates from the QNX data structure to Qt coordinates
|
||||
// note the swapped y axis
|
||||
QPoint pos = mousePos;
|
||||
pos += QPoint(packet.dx, -packet.dy);
|
||||
|
||||
// QNX only tells us relative mouse movements, not absolute ones, so limit the
|
||||
// cursor position manually to the screen
|
||||
limitToScreen(pos);
|
||||
|
||||
// translate the QNX mouse button bitmask to Qt buttons
|
||||
int buttons = Qt::NoButton;
|
||||
|
||||
if (packet.hdr.buttons & _POINTER_BUTTON_LEFT)
|
||||
buttons |= Qt::LeftButton;
|
||||
if (packet.hdr.buttons & _POINTER_BUTTON_MIDDLE)
|
||||
buttons |= Qt::MidButton;
|
||||
if (packet.hdr.buttons & _POINTER_BUTTON_RIGHT)
|
||||
buttons |= Qt::RightButton;
|
||||
|
||||
// call mouseChanged() - this does all the magic to actually move the on-screen
|
||||
// mouse cursor.
|
||||
mouseChanged(pos, buttons, 0);
|
||||
} while (++iteration < 11);
|
||||
}
|
||||
|
||||
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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSE_QNX_H
|
||||
#define QMOUSE_QNX_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
class Q_GUI_EXPORT QQnxMouseHandler : public QObject, public QWSMouseHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQnxMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
~QQnxMouseHandler();
|
||||
|
||||
void resume();
|
||||
void suspend();
|
||||
|
||||
private Q_SLOTS:
|
||||
void socketActivated();
|
||||
|
||||
private:
|
||||
QSocketNotifier *mouseNotifier;
|
||||
int mouseFD;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSE_QWS_H
|
@ -1,371 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmousetslib_qws.h"
|
||||
|
||||
#if !defined(QT_NO_QWS_MOUSE_TSLIB) || defined(QT_PLUGIN)
|
||||
|
||||
#include <QtCore/qregexp.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include "qsocketnotifier.h"
|
||||
#include "qscreen_qws.h"
|
||||
|
||||
#include <tslib.h>
|
||||
#include <errno.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef TSLIBMOUSEHANDLER_DEBUG
|
||||
# include <QtCore/QDebug>
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
\class QWSTslibMouseHandler
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSTslibMouseHandler class implements a mouse driver
|
||||
for the Universal Touch Screen Library, tslib.
|
||||
|
||||
QWSTslibMouseHandler inherits the QWSCalibratedMouseHandler class,
|
||||
providing calibration and noise reduction functionality in
|
||||
addition to generating mouse events, for devices using the
|
||||
Universal Touch Screen Library.
|
||||
|
||||
To be able to compile this mouse handler, \l{Qt for Embedded Linux}
|
||||
must be configured with the \c -qt-mouse-tslib option, see the
|
||||
\l{Pointer Handling} documentation for details. In addition, the tslib
|
||||
headers and library must be present in the build environment. The
|
||||
tslib sources can be downloaded from \l
|
||||
{http://tslib.berlios.de/}. Use the \c -L and \c -I options
|
||||
with \c configure to explicitly specify the location of the
|
||||
library and its headers:
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp 0
|
||||
|
||||
In order to use this mouse handler, tslib must also be correctly
|
||||
installed on the target machine. This includes providing a \c
|
||||
ts.conf configuration file and setting the necessary environment
|
||||
variables, see the README file provided with tslib for details.
|
||||
|
||||
The ts.conf file will usually contain the following two lines
|
||||
|
||||
\snippet doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp 1
|
||||
|
||||
To make \l{Qt for Embedded Linux} explicitly choose the tslib mouse
|
||||
handler, set the QWS_MOUSE_PROTO environment variable.
|
||||
|
||||
\sa {Pointer Handling}, {Qt for Embedded Linux}
|
||||
*/
|
||||
|
||||
class QWSTslibMouseHandlerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSTslibMouseHandlerPrivate(QWSTslibMouseHandler *h,
|
||||
const QString &device);
|
||||
~QWSTslibMouseHandlerPrivate();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
void calibrate(const QWSPointerCalibrationData *data);
|
||||
void clearCalibration();
|
||||
|
||||
private:
|
||||
QWSTslibMouseHandler *handler;
|
||||
struct tsdev *dev;
|
||||
QSocketNotifier *mouseNotifier;
|
||||
int jitter_limit;
|
||||
|
||||
struct ts_sample lastSample;
|
||||
bool wasPressed;
|
||||
int lastdx;
|
||||
int lastdy;
|
||||
|
||||
bool calibrated;
|
||||
QString devName;
|
||||
|
||||
bool open();
|
||||
void close();
|
||||
inline bool get_sample(struct ts_sample *sample);
|
||||
|
||||
private slots:
|
||||
void readMouseData();
|
||||
};
|
||||
|
||||
QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(QWSTslibMouseHandler *h,
|
||||
const QString &device)
|
||||
: handler(h), dev(0), mouseNotifier(0), jitter_limit(3)
|
||||
{
|
||||
QStringList args = device.split(QLatin1Char(':'), QString::SkipEmptyParts);
|
||||
QRegExp jitterRegex(QLatin1String("^jitter_limit=(\\d+)$"));
|
||||
int index = args.indexOf(jitterRegex);
|
||||
if (index >= 0) {
|
||||
jitter_limit = jitterRegex.cap(1).toInt();
|
||||
args.removeAt(index);
|
||||
}
|
||||
|
||||
devName = args.join(QString());
|
||||
|
||||
if (devName.isNull()) {
|
||||
const char *str = getenv("TSLIB_TSDEVICE");
|
||||
if (str)
|
||||
devName = QString::fromLocal8Bit(str);
|
||||
}
|
||||
|
||||
if (devName.isNull())
|
||||
devName = QLatin1String("/dev/ts");
|
||||
|
||||
if (!open())
|
||||
return;
|
||||
|
||||
calibrated = true;
|
||||
|
||||
int fd = ts_fd(dev);
|
||||
mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
||||
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
|
||||
resume();
|
||||
}
|
||||
|
||||
QWSTslibMouseHandlerPrivate::~QWSTslibMouseHandlerPrivate()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool QWSTslibMouseHandlerPrivate::open()
|
||||
{
|
||||
dev = ts_open(devName.toLocal8Bit().constData(), 1);
|
||||
if (!dev) {
|
||||
qCritical("QWSTslibMouseHandlerPrivate: ts_open() failed"
|
||||
" with error: '%s'", strerror(errno));
|
||||
qCritical("Please check your tslib installation!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ts_config(dev)) {
|
||||
qCritical("QWSTslibMouseHandlerPrivate: ts_config() failed"
|
||||
" with error: '%s'", strerror(errno));
|
||||
qCritical("Please check your tslib installation!");
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::close()
|
||||
{
|
||||
if (dev)
|
||||
ts_close(dev);
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::suspend()
|
||||
{
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(false);
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::resume()
|
||||
{
|
||||
memset(&lastSample, 0, sizeof(lastSample));
|
||||
wasPressed = false;
|
||||
lastdx = 0;
|
||||
lastdy = 0;
|
||||
if (mouseNotifier)
|
||||
mouseNotifier->setEnabled(true);
|
||||
}
|
||||
|
||||
bool QWSTslibMouseHandlerPrivate::get_sample(struct ts_sample *sample)
|
||||
{
|
||||
if (!calibrated)
|
||||
return (ts_read_raw(dev, sample, 1) == 1);
|
||||
|
||||
return (ts_read(dev, sample, 1) == 1);
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::readMouseData()
|
||||
{
|
||||
if (!qt_screen)
|
||||
return;
|
||||
|
||||
for(;;) {
|
||||
struct ts_sample sample = lastSample;
|
||||
bool pressed = wasPressed;
|
||||
|
||||
// Fast return if there's no events.
|
||||
if (!get_sample(&sample))
|
||||
return;
|
||||
pressed = (sample.pressure > 0);
|
||||
|
||||
// Only return last sample unless there's a press/release event.
|
||||
while (pressed == wasPressed) {
|
||||
if (!get_sample(&sample))
|
||||
break;
|
||||
pressed = (sample.pressure > 0);
|
||||
}
|
||||
|
||||
// work around missing coordinates on mouse release in raw mode
|
||||
if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
|
||||
sample.x = lastSample.x;
|
||||
sample.y = lastSample.y;
|
||||
}
|
||||
|
||||
int dx = sample.x - lastSample.x;
|
||||
int dy = sample.y - lastSample.y;
|
||||
|
||||
// Remove small movements in oppsite direction
|
||||
if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
|
||||
sample.x = lastSample.x;
|
||||
dx = 0;
|
||||
}
|
||||
if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
|
||||
sample.y = lastSample.y;
|
||||
dy = 0;
|
||||
}
|
||||
|
||||
if (wasPressed == pressed && dx == 0 && dy == 0)
|
||||
return;
|
||||
|
||||
#ifdef TSLIBMOUSEHANDLER_DEBUG
|
||||
qDebug() << "last" << QPoint(lastSample.x, lastSample.y)
|
||||
<< "curr" << QPoint(sample.x, sample.y)
|
||||
<< "dx,dy" << QPoint(dx, dy)
|
||||
<< "ddx,ddy" << QPoint(dx*lastdx, dy*lastdy)
|
||||
<< "pressed" << wasPressed << pressed;
|
||||
#endif
|
||||
|
||||
lastSample = sample;
|
||||
wasPressed = pressed;
|
||||
if (dx != 0)
|
||||
lastdx = dx;
|
||||
if (dy != 0)
|
||||
lastdy = dy;
|
||||
|
||||
const QPoint p(sample.x, sample.y);
|
||||
if (calibrated) {
|
||||
// tslib should do all the translation and filtering, so we send a
|
||||
// "raw" mouse event
|
||||
handler->QWSMouseHandler::mouseChanged(p, pressed);
|
||||
} else {
|
||||
handler->sendFiltered(p, pressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::clearCalibration()
|
||||
{
|
||||
suspend();
|
||||
close();
|
||||
handler->QWSCalibratedMouseHandler::clearCalibration();
|
||||
calibrated = false;
|
||||
open();
|
||||
resume();
|
||||
}
|
||||
|
||||
void QWSTslibMouseHandlerPrivate::calibrate(const QWSPointerCalibrationData *data)
|
||||
{
|
||||
suspend();
|
||||
close();
|
||||
// default implementation writes to /etc/pointercal
|
||||
// using the same format as the tslib linear module.
|
||||
handler->QWSCalibratedMouseHandler::calibrate(data);
|
||||
calibrated = true;
|
||||
open();
|
||||
resume();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QWSTslibMouseHandler::QWSTslibMouseHandler(const QString &driver,
|
||||
const QString &device)
|
||||
: QWSCalibratedMouseHandler(driver, device)
|
||||
{
|
||||
d = new QWSTslibMouseHandlerPrivate(this, device);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QWSTslibMouseHandler::~QWSTslibMouseHandler()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QWSTslibMouseHandler::suspend()
|
||||
{
|
||||
d->suspend();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QWSTslibMouseHandler::resume()
|
||||
{
|
||||
d->resume();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QWSTslibMouseHandler::clearCalibration()
|
||||
{
|
||||
d->clearCalibration();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QWSTslibMouseHandler::calibrate(const QWSPointerCalibrationData *data)
|
||||
{
|
||||
d->calibrate(data);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "qmousetslib_qws.moc"
|
||||
|
||||
#endif //QT_NO_QWS_MOUSE_TSLIB
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSETSLIB_QWS_H
|
||||
#define QMOUSETSLIB_QWS_H
|
||||
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if !defined(QT_NO_QWS_MOUSE_TSLIB) || defined(QT_PLUGIN)
|
||||
|
||||
class QWSTslibMouseHandlerPrivate;
|
||||
|
||||
class QWSTslibMouseHandler : public QWSCalibratedMouseHandler
|
||||
{
|
||||
public:
|
||||
explicit QWSTslibMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
~QWSTslibMouseHandler();
|
||||
|
||||
void suspend();
|
||||
void resume();
|
||||
|
||||
void calibrate(const QWSPointerCalibrationData *data);
|
||||
void clearCalibration();
|
||||
|
||||
protected:
|
||||
friend class QWSTslibMouseHandlerPrivate;
|
||||
QWSTslibMouseHandlerPrivate *d;
|
||||
};
|
||||
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_TSLIB
|
||||
QT_END_NAMESPACE
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSETSLIB_QWS_H
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_QVFB
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <qvfbhdr.h>
|
||||
#include <qmousevfb_qws.h>
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include <qapplication.h>
|
||||
#include <qtimer.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
|
||||
: QObject(), QWSMouseHandler(driver, device)
|
||||
{
|
||||
QString mouseDev = device;
|
||||
if (device.isEmpty())
|
||||
mouseDev = QLatin1String("/dev/vmouse");
|
||||
|
||||
mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
|
||||
if (mouseFD == -1) {
|
||||
perror("QVFbMouseHandler::QVFbMouseHandler");
|
||||
qWarning("QVFbMouseHander: Unable to open device %s",
|
||||
qPrintable(mouseDev));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear pending input
|
||||
char buf[2];
|
||||
while (QT_READ(mouseFD, buf, 1) > 0) { }
|
||||
|
||||
mouseIdx = 0;
|
||||
|
||||
mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
|
||||
connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
|
||||
}
|
||||
|
||||
QVFbMouseHandler::~QVFbMouseHandler()
|
||||
{
|
||||
if (mouseFD >= 0)
|
||||
QT_CLOSE(mouseFD);
|
||||
}
|
||||
|
||||
void QVFbMouseHandler::resume()
|
||||
{
|
||||
mouseNotifier->setEnabled(true);
|
||||
}
|
||||
|
||||
void QVFbMouseHandler::suspend()
|
||||
{
|
||||
mouseNotifier->setEnabled(false);
|
||||
}
|
||||
|
||||
void QVFbMouseHandler::readMouseData()
|
||||
{
|
||||
int n;
|
||||
do {
|
||||
n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
|
||||
if (n > 0)
|
||||
mouseIdx += n;
|
||||
} while (n > 0);
|
||||
|
||||
int idx = 0;
|
||||
static const int packetsize = sizeof(QPoint) + 2*sizeof(int);
|
||||
while (mouseIdx-idx >= packetsize) {
|
||||
uchar *mb = mouseBuf+idx;
|
||||
QPoint mousePos = *reinterpret_cast<QPoint *>(mb);
|
||||
mb += sizeof(QPoint);
|
||||
int bstate = *reinterpret_cast<int *>(mb);
|
||||
mb += sizeof(int);
|
||||
int wheel = *reinterpret_cast<int *>(mb);
|
||||
// limitToScreen(mousePos);
|
||||
mouseChanged(mousePos, bstate, wheel);
|
||||
idx += packetsize;
|
||||
}
|
||||
|
||||
int surplus = mouseIdx - idx;
|
||||
for (int i = 0; i < surplus; i++)
|
||||
mouseBuf[i] = mouseBuf[idx+i];
|
||||
mouseIdx = surplus;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_MOUSE_QVFB
|
@ -1,83 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEVFB_QWS_H
|
||||
#define QMOUSEVFB_QWS_H
|
||||
|
||||
#include <QtGui/qmouse_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MOUSE_QVFB
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
class QVFbMouseHandler : public QObject, public QWSMouseHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVFbMouseHandler(const QString &driver = QString(),
|
||||
const QString &device = QString());
|
||||
~QVFbMouseHandler();
|
||||
|
||||
void resume();
|
||||
void suspend();
|
||||
|
||||
private:
|
||||
int mouseFD;
|
||||
int mouseIdx;
|
||||
enum {mouseBufSize = 128};
|
||||
uchar mouseBuf[mouseBufSize];
|
||||
QSocketNotifier *mouseNotifier;
|
||||
|
||||
private Q_SLOTS:
|
||||
void readMouseData();
|
||||
};
|
||||
#endif // QT_NO_QWS_MOUSE_QVFB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMOUSEVFB_QWS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,391 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREEN_QWS_H
|
||||
#define QSCREEN_QWS_H
|
||||
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QtCore/qpoint.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtGui/qrgb.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qregion.h>
|
||||
|
||||
struct fb_cmap;
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QScreenCursor;
|
||||
class QBrush;
|
||||
class QWSWindow;
|
||||
class QWSWindowSurface;
|
||||
class QGraphicsSystem;
|
||||
class QPixmapData;
|
||||
|
||||
#ifndef QT_QWS_DEPTH16_RGB
|
||||
#define QT_QWS_DEPTH16_RGB 565
|
||||
#endif
|
||||
static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
|
||||
static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
|
||||
static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
|
||||
static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
|
||||
static const int qt_green_shift = qt_bbits-(8-qt_gbits);
|
||||
static const int qt_neg_blue_shift = 8-qt_bbits;
|
||||
static const int qt_blue_mask = (1<<qt_bbits)-1;
|
||||
static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
|
||||
static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
|
||||
|
||||
static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
|
||||
static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
|
||||
static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
|
||||
|
||||
|
||||
inline ushort qt_convRgbTo16(const int r, const int g, const int b)
|
||||
{
|
||||
const int tr = r << qt_red_shift;
|
||||
const int tg = g << qt_green_shift;
|
||||
const int tb = b >> qt_neg_blue_shift;
|
||||
|
||||
return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
|
||||
}
|
||||
|
||||
inline ushort qt_convRgbTo16(QRgb c)
|
||||
{
|
||||
const int tr = qRed(c) << qt_red_shift;
|
||||
const int tg = qGreen(c) << qt_green_shift;
|
||||
const int tb = qBlue(c) >> qt_neg_blue_shift;
|
||||
|
||||
return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
|
||||
}
|
||||
|
||||
inline QRgb qt_conv16ToRgb(ushort c)
|
||||
{
|
||||
const int r=(c & qt_red_mask);
|
||||
const int g=(c & qt_green_mask);
|
||||
const int b=(c & qt_blue_mask);
|
||||
const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
|
||||
const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
|
||||
const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
|
||||
|
||||
return qRgb(tr,tg,tb);
|
||||
}
|
||||
|
||||
inline void qt_conv16ToRgb(ushort c, int& r, int& g, int& b)
|
||||
{
|
||||
const int tr=(c & qt_red_mask);
|
||||
const int tg=(c & qt_green_mask);
|
||||
const int tb=(c & qt_blue_mask);
|
||||
r = tr >> qt_red_shift | tr >> qt_red_rounding_shift;
|
||||
g = tg >> qt_green_shift | tg >> qt_green_rounding_shift;
|
||||
b = tb << qt_neg_blue_shift | tb >> qt_blue_rounding_shift;
|
||||
}
|
||||
|
||||
const int SourceSolid=0;
|
||||
const int SourcePixmap=1;
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
|
||||
class QScreenCursor;
|
||||
extern QScreenCursor *qt_screencursor;
|
||||
extern bool qws_sw_cursor;
|
||||
|
||||
class Q_GUI_EXPORT QScreenCursor
|
||||
{
|
||||
public:
|
||||
QScreenCursor();
|
||||
virtual ~QScreenCursor();
|
||||
|
||||
virtual void set(const QImage &image, int hotx, int hoty);
|
||||
virtual void move(int x, int y);
|
||||
virtual void show();
|
||||
virtual void hide();
|
||||
|
||||
bool supportsAlphaCursor() const { return supportsAlpha; }
|
||||
|
||||
static bool enabled() { return qws_sw_cursor; }
|
||||
|
||||
QRect boundingRect() const { return QRect(pos - hotspot, size); }
|
||||
QImage image() const { return cursor; }
|
||||
bool isVisible() const { return enable; }
|
||||
bool isAccelerated() const { return hwaccel; }
|
||||
|
||||
static void initSoftwareCursor();
|
||||
static QScreenCursor* instance() { return qt_screencursor; }
|
||||
|
||||
protected:
|
||||
QImage cursor;
|
||||
|
||||
QSize size;
|
||||
QPoint pos;
|
||||
QPoint hotspot;
|
||||
uint enable : 1;
|
||||
uint hwaccel : 1;
|
||||
uint supportsAlpha : 1;
|
||||
|
||||
private:
|
||||
friend class QProxyScreenCursor;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_CURSOR
|
||||
|
||||
// A (used) chunk of offscreen memory
|
||||
|
||||
class QPoolEntry
|
||||
{
|
||||
public:
|
||||
unsigned int start;
|
||||
unsigned int end;
|
||||
int clientId;
|
||||
};
|
||||
|
||||
class QScreen;
|
||||
class QScreenPrivate;
|
||||
class QPixmapDataFactory;
|
||||
|
||||
extern Q_GUI_EXPORT QScreen *qt_screen;
|
||||
typedef void(*ClearCacheFunc)(QScreen *obj, int);
|
||||
|
||||
class Q_GUI_EXPORT QScreen {
|
||||
|
||||
public:
|
||||
enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
|
||||
VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
|
||||
GLClass, IntfbClass, CustomClass = 1024 };
|
||||
|
||||
QScreen(int display_id, ClassId classId);
|
||||
explicit QScreen(int display_id);
|
||||
virtual ~QScreen();
|
||||
static QScreen* instance() { return qt_screen; }
|
||||
virtual bool initDevice() = 0;
|
||||
virtual bool connect(const QString &displaySpec) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
virtual void shutdownDevice();
|
||||
virtual void setMode(int,int,int) = 0;
|
||||
virtual bool supportsDepth(int) const;
|
||||
|
||||
virtual void save();
|
||||
virtual void restore();
|
||||
virtual void blank(bool on);
|
||||
|
||||
virtual int pixmapOffsetAlignment() { return 64; }
|
||||
virtual int pixmapLinestepAlignment() { return 64; }
|
||||
virtual int sharedRamSize(void *) { return 0; }
|
||||
|
||||
virtual bool onCard(const unsigned char *) const;
|
||||
virtual bool onCard(const unsigned char *, ulong& out_offset) const;
|
||||
|
||||
enum PixelType { NormalPixel, BGRPixel };
|
||||
|
||||
// sets a single color in the colormap
|
||||
virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
|
||||
// allocates a color
|
||||
virtual int alloc(unsigned int,unsigned int,unsigned int);
|
||||
|
||||
int width() const { return w; }
|
||||
int height() const { return h; }
|
||||
int depth() const { return d; }
|
||||
virtual int pixmapDepth() const;
|
||||
PixelType pixelType() const { return pixeltype; }
|
||||
int linestep() const { return lstep; }
|
||||
int deviceWidth() const { return dw; }
|
||||
int deviceHeight() const { return dh; }
|
||||
uchar * base() const { return data; }
|
||||
// Ask for memory from card cache with alignment
|
||||
virtual uchar * cache(int) { return 0; }
|
||||
virtual void uncache(uchar *) {}
|
||||
|
||||
QImage::Format pixelFormat() const;
|
||||
|
||||
int screenSize() const { return size; }
|
||||
int totalSize() const { return mapsize; }
|
||||
|
||||
QRgb * clut() { return screenclut; }
|
||||
#ifdef QT_DEPRECATED
|
||||
QT_DEPRECATED int numCols() { return screencols; }
|
||||
#endif
|
||||
int colorCount() { return screencols; }
|
||||
|
||||
virtual QSize mapToDevice(const QSize &) const;
|
||||
virtual QSize mapFromDevice(const QSize &) const;
|
||||
virtual QPoint mapToDevice(const QPoint &, const QSize &) const;
|
||||
virtual QPoint mapFromDevice(const QPoint &, const QSize &) const;
|
||||
virtual QRect mapToDevice(const QRect &, const QSize &) const;
|
||||
virtual QRect mapFromDevice(const QRect &, const QSize &) const;
|
||||
virtual QImage mapToDevice(const QImage &) const;
|
||||
virtual QImage mapFromDevice(const QImage &) const;
|
||||
virtual QRegion mapToDevice(const QRegion &, const QSize &) const;
|
||||
virtual QRegion mapFromDevice(const QRegion &, const QSize &) const;
|
||||
virtual int transformOrientation() const;
|
||||
virtual bool isTransformed() const;
|
||||
virtual bool isInterlaced() const;
|
||||
|
||||
virtual void setDirty(const QRect&);
|
||||
|
||||
virtual int memoryNeeded(const QString&);
|
||||
|
||||
virtual void haltUpdates();
|
||||
virtual void resumeUpdates();
|
||||
|
||||
// composition manager methods
|
||||
virtual void exposeRegion(QRegion r, int changing);
|
||||
|
||||
// these work directly on the screen
|
||||
virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion);
|
||||
virtual void solidFill(const QColor &color, const QRegion ®ion);
|
||||
void blit(QWSWindow *bs, const QRegion &clip);
|
||||
|
||||
virtual QWSWindowSurface* createSurface(QWidget *widget) const;
|
||||
virtual QWSWindowSurface* createSurface(const QString &key) const;
|
||||
|
||||
virtual QList<QScreen*> subScreens() const { return QList<QScreen*>(); }
|
||||
virtual QRegion region() const { return QRect(offset(), QSize(w, h)); }
|
||||
int subScreenIndexAt(const QPoint &p) const;
|
||||
|
||||
void setOffset(const QPoint &p);
|
||||
QPoint offset() const;
|
||||
|
||||
int physicalWidth() const { return physWidth; } // physical display size in mm
|
||||
int physicalHeight() const { return physHeight; } // physical display size in mm
|
||||
|
||||
QPixmapDataFactory* pixmapDataFactory() const; // Deprecated, will be removed in 4.6
|
||||
QGraphicsSystem* graphicsSystem() const;
|
||||
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
bool supportsBlitInClients() const;
|
||||
void setSupportsBlitInClients(bool);
|
||||
#endif
|
||||
|
||||
ClassId classId() const;
|
||||
|
||||
protected:
|
||||
void setPixelFormat(QImage::Format format);
|
||||
void setPixmapDataFactory(QPixmapDataFactory *factory); // Deprecated, will be removed in 4.6
|
||||
void setGraphicsSystem(QGraphicsSystem* system);
|
||||
|
||||
QRgb screenclut[256];
|
||||
int screencols;
|
||||
|
||||
uchar * data;
|
||||
|
||||
// Table of allocated lumps, kept in sorted highest-to-lowest order
|
||||
// The table itself is allocated at the bottom of offscreen memory
|
||||
// i.e. it's similar to having a stack (the table) and a heap
|
||||
// (the allocated blocks). Freed space is implicitly described
|
||||
// by the gaps between the allocated lumps (this saves entries and
|
||||
// means we don't need to worry about coalescing freed lumps)
|
||||
|
||||
QPoolEntry * entries;
|
||||
int * entryp;
|
||||
unsigned int * lowest;
|
||||
|
||||
int w;
|
||||
int lstep;
|
||||
int h;
|
||||
int d;
|
||||
PixelType pixeltype;
|
||||
bool grayscale;
|
||||
|
||||
int dw;
|
||||
int dh;
|
||||
|
||||
int size; // Screen size
|
||||
int mapsize; // Total mapped memory
|
||||
|
||||
int displayId;
|
||||
|
||||
int physWidth;
|
||||
int physHeight;
|
||||
|
||||
friend class QWSServer;
|
||||
friend class QWSServerPrivate;
|
||||
static ClearCacheFunc clearCacheFunc;
|
||||
|
||||
private:
|
||||
void compose(int level, const QRegion &exposed, QRegion &blend,
|
||||
QImage **blendbuffer, int changing_level);
|
||||
void paintBackground(const QRegion &);
|
||||
|
||||
friend class QWSOnScreenSurface;
|
||||
static bool isWidgetPaintOnScreen(const QWidget *w);
|
||||
|
||||
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
||||
void setFrameBufferLittleEndian(bool littleEndian);
|
||||
bool frameBufferLittleEndian() const;
|
||||
friend class QVNCScreen;
|
||||
friend class QLinuxFbScreen;
|
||||
friend class QVFbScreen;
|
||||
friend class QProxyScreen;
|
||||
friend class QIntfbScreen;
|
||||
#endif
|
||||
friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
|
||||
friend void qt_blit_setup(QScreen *screen, const QImage &image,
|
||||
const QPoint &topLeft, const QRegion ®ion);
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
friend void qt_set_generic_blit(QScreen *screen, int bpp,
|
||||
int len_red, int len_green, int len_blue,
|
||||
int len_alpha, int off_red, int off_green,
|
||||
int off_blue, int off_alpha);
|
||||
#endif
|
||||
|
||||
QScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
// This lives in loadable modules
|
||||
|
||||
#ifndef QT_LOADABLE_MODULES
|
||||
extern "C" QScreen * qt_get_screen(int display_id, const char* spec);
|
||||
#endif
|
||||
|
||||
// This is in main lib, loads the right module, calls qt_get_screen
|
||||
// In non-loadable cases just aliases to qt_get_screen
|
||||
|
||||
const unsigned char * qt_probe_bus();
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREEN_QWS_H
|
@ -1,204 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qscreendriverfactory_qws.h"
|
||||
|
||||
#include "qscreen_qws.h"
|
||||
#include "qapplication.h"
|
||||
#include "qscreenlinuxfb_qws.h"
|
||||
#include "qscreentransformed_qws.h"
|
||||
#include "qscreenvfb_qws.h"
|
||||
#include "qscreenmulti_qws_p.h"
|
||||
#include "qscreenqnx_qws.h"
|
||||
#include "qscreenintegrityfb_qws.h"
|
||||
#include <stdlib.h>
|
||||
#include "private/qfactoryloader_p.h"
|
||||
#include "qscreendriverplugin_qws.h"
|
||||
#ifndef QT_NO_QWS_DIRECTFB
|
||||
#include "qdirectfbscreen.h"
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_VNC
|
||||
#include "qscreenvnc_qws.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QScreenDriverFactoryInterface_iid,
|
||||
QLatin1String("/gfxdrivers"), Qt::CaseInsensitive))
|
||||
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
|
||||
/*!
|
||||
\class QScreenDriverFactory
|
||||
\ingroup qws
|
||||
|
||||
\brief The QScreenDriverFactory class creates screen drivers in
|
||||
Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
QScreenDriverFactory is used to detect and instantiate the
|
||||
available screen drivers, allowing \l{Qt for Embedded Linux} to load the
|
||||
preferred driver into the server application at runtime. The
|
||||
create() function returns a QScreen object representing the screen
|
||||
driver identified by a given key. The valid keys (i.e. the
|
||||
supported drivers) can be retrieved using the keys() function.
|
||||
|
||||
|
||||
\l{Qt for Embedded Linux} provides several built-in screen drivers. In
|
||||
addition, custom screen drivers can be added using Qt's plugin
|
||||
mechanism, i.e. by subclassing the QScreen class and creating a
|
||||
screen driver plugin (QScreenDriverPlugin). See the
|
||||
\l{Qt for Embedded Linux Display Management}{display management}
|
||||
documentation for details.
|
||||
|
||||
\sa QScreen, QScreenDriverPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Creates the screen driver specified by the given \a key, using the
|
||||
display specified by the given \a displayId.
|
||||
|
||||
Note that the keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
QScreen *QScreenDriverFactory::create(const QString& key, int displayId)
|
||||
{
|
||||
QString driver = key.toLower();
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
|
||||
if (driver == QLatin1String("qnx") || driver.isEmpty())
|
||||
return new QQnxScreen(displayId);
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
|
||||
if (driver == QLatin1String("integrityfb") || driver.isEmpty())
|
||||
return new QIntfbScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_QVFB
|
||||
if (driver == QLatin1String("qvfb") || driver.isEmpty())
|
||||
return new QVFbScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_LINUXFB
|
||||
if (driver == QLatin1String("linuxfb") || driver.isEmpty())
|
||||
return new QLinuxFbScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_DIRECTFB
|
||||
if (driver == QLatin1String("directfb") || driver.isEmpty())
|
||||
return new QDirectFBScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_TRANSFORMED
|
||||
if (driver == QLatin1String("transformed"))
|
||||
return new QTransformedScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_VNC
|
||||
if (driver == QLatin1String("vnc"))
|
||||
return new QVNCScreen(displayId);
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MULTISCREEN
|
||||
if (driver == QLatin1String("multi"))
|
||||
return new QMultiScreen(displayId);
|
||||
#endif
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
if (QScreenDriverFactoryInterface *factory = qobject_cast<QScreenDriverFactoryInterface*>(loader()->instance(key)))
|
||||
return factory->create(driver, displayId);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of valid keys, i.e. the available screen drivers.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
QStringList QScreenDriverFactory::keys()
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
|
||||
list << QLatin1String("QNX");
|
||||
#endif
|
||||
#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
|
||||
list << QLatin1String("INTEGRITYFB");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_QVFB
|
||||
list << QLatin1String("QVFb");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_LINUXFB
|
||||
list << QLatin1String("LinuxFb");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_TRANSFORMED
|
||||
list << QLatin1String("Transformed");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_VNC
|
||||
list << QLatin1String("VNC");
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_MULTISCREEN
|
||||
list << QLatin1String("Multi");
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
|
||||
#ifndef QT_NO_LIBRARY
|
||||
QStringList plugins = loader()->keys();
|
||||
for (int i = 0; i < plugins.size(); ++i) {
|
||||
# ifdef QT_NO_QWS_QVFB
|
||||
// give QVFb top priority for autodetection
|
||||
if (plugins.at(i) == QLatin1String("QVFb"))
|
||||
list.prepend(plugins.at(i));
|
||||
else
|
||||
# endif
|
||||
if (!list.contains(plugins.at(i)))
|
||||
list += plugins.at(i);
|
||||
}
|
||||
#endif //QT_NO_LIBRARY
|
||||
#endif //QT_MAKEDLL
|
||||
return list;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,67 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENDRIVERFACTORY_QWS_H
|
||||
#define QSCREENDRIVERFACTORY_QWS_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QString;
|
||||
class QScreen;
|
||||
|
||||
class Q_GUI_EXPORT QScreenDriverFactory
|
||||
{
|
||||
public:
|
||||
static QStringList keys();
|
||||
static QScreen *create(const QString&, int);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENDRIVERFACTORY_QWS_H
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qscreendriverplugin_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
/*!
|
||||
\class QScreenDriverPlugin
|
||||
\ingroup plugins
|
||||
\ingroup qws
|
||||
|
||||
\brief The QScreenDriverPlugin class is an abstract base class for
|
||||
screen driver plugins in Qt for Embedded Linux.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several screen
|
||||
protocols, see the \l{Qt for Embedded Linux Display Management}{display
|
||||
management} documentation for details. Custom screen drivers can be
|
||||
implemented by subclassing the QScreen class and creating a screen
|
||||
driver plugin.
|
||||
|
||||
A screen driver plugin can be created by subclassing
|
||||
QScreenDriverPlugin and reimplementing the pure virtual keys() and
|
||||
create() functions. By exporting the derived class using the
|
||||
Q_EXPORT_PLUGIN2() macro, The default implementation of the
|
||||
QScreenDriverFactory class will automatically detect the plugin
|
||||
and load the driver into the server application at run-time. See
|
||||
\l{How to Create Qt Plugins} for details.
|
||||
|
||||
\sa QScreen, QScreenDriverFactory
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QScreenDriverPlugin::keys() const
|
||||
|
||||
Implement this function to return the list of valid keys, i.e. the
|
||||
screen drivers supported by this plugin.
|
||||
|
||||
\l{Qt for Embedded Linux} provides ready-made drivers for several screen
|
||||
protocols, see the \l{Qt for Embedded Linux Display Management}{display
|
||||
management} documentation for details.
|
||||
|
||||
\sa create()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a screen driver plugin with the given \a parent.
|
||||
|
||||
Note that this constructor is invoked automatically by the
|
||||
Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
|
||||
explicitly.
|
||||
*/
|
||||
QScreenDriverPlugin::QScreenDriverPlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this screen driver plugin.
|
||||
|
||||
Note that Qt destroys a plugin automatically when it is no longer
|
||||
used, so there is no need for calling the destructor explicitly.
|
||||
*/
|
||||
QScreenDriverPlugin::~QScreenDriverPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn QScreen* QScreenDriverPlugin::create(const QString &key, int displayId)
|
||||
|
||||
Implement this function to create a driver matching the type
|
||||
specified by the given \a key and \a displayId parameters. Note
|
||||
that keys are case-insensitive.
|
||||
|
||||
\sa keys()
|
||||
*/
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
||||
|
||||
QT_END_NAMESPACE
|
@ -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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENDRIVERPLUGIN_QWS_H
|
||||
#define QSCREENDRIVERPLUGIN_QWS_H
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
||||
class QScreen;
|
||||
|
||||
struct Q_GUI_EXPORT QScreenDriverFactoryInterface : public QFactoryInterface
|
||||
{
|
||||
virtual QScreen* create(const QString& driver, int displayId) = 0;
|
||||
};
|
||||
|
||||
#define QScreenDriverFactoryInterface_iid "com.trolltech.Qt.QScreenDriverFactoryInterface"
|
||||
Q_DECLARE_INTERFACE(QScreenDriverFactoryInterface, QScreenDriverFactoryInterface_iid)
|
||||
|
||||
class Q_GUI_EXPORT QScreenDriverPlugin : public QObject, public QScreenDriverFactoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QScreenDriverFactoryInterface:QFactoryInterface)
|
||||
public:
|
||||
explicit QScreenDriverPlugin(QObject *parent = 0);
|
||||
~QScreenDriverPlugin();
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QScreen *create(const QString& driver, int displayId) = 0;
|
||||
};
|
||||
|
||||
#endif // QT_NO_LIBRARY
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENDRIVERPLUGIN_QWS_H
|
@ -1,405 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_INTEGRITYFB
|
||||
|
||||
#include <qscreenintegrityfb_qws.h>
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include <qapplication.h>
|
||||
#include <qscreen_qws.h>
|
||||
#include "qmouseintegrity_qws.h"
|
||||
#include "qkbdintegrity_qws.h"
|
||||
#include <qmousedriverfactory_qws.h>
|
||||
#include <qkbddriverfactory_qws.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <INTEGRITY.h>
|
||||
#include <device/fbdriver.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIntfbScreenPrivate
|
||||
{
|
||||
public:
|
||||
QIntfbScreenPrivate();
|
||||
~QIntfbScreenPrivate();
|
||||
|
||||
FBHandle handle;
|
||||
struct FBInfoStruct fbinfo;
|
||||
|
||||
QWSMouseHandler *mouse;
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
QWSKeyboardHandler *keyboard;
|
||||
#endif
|
||||
};
|
||||
|
||||
QIntfbScreenPrivate::QIntfbScreenPrivate()
|
||||
: mouse(0)
|
||||
|
||||
{
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
keyboard = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
QIntfbScreenPrivate::~QIntfbScreenPrivate()
|
||||
{
|
||||
delete mouse;
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
delete keyboard;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
\class QIntfbScreen
|
||||
\ingroup qws
|
||||
|
||||
\brief The QIntfbScreen class implements a screen driver for the
|
||||
INTEGRITY framebuffer drivers.
|
||||
|
||||
Note that this class is only available in \l{Qt for INTEGRITY}.
|
||||
Custom screen drivers can be added by subclassing the
|
||||
QScreenDriverPlugin class, using the QScreenDriverFactory class to
|
||||
dynamically load the driver into the application, but there should
|
||||
only be one screen object per application.
|
||||
|
||||
\sa QScreen, QScreenDriverPlugin, {Running Applications}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QIntfbScreen::connect(const QString & displaySpec)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::disconnect()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QIntfbScreen::initDevice()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::restore()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::save()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::setDirty(const QRect & r)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::setMode(int nw, int nh, int nd)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QIntfbScreen::shutdownDevice()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QIntfbScreen::QIntfbScreen(int displayId)
|
||||
|
||||
Constructs a QVNCScreen object. The \a displayId argument
|
||||
identifies the Qt for Embedded Linux server to connect to.
|
||||
*/
|
||||
QIntfbScreen::QIntfbScreen(int display_id)
|
||||
: QScreen(display_id, IntfbClass), d_ptr(new QIntfbScreenPrivate)
|
||||
{
|
||||
d_ptr->handle = 0;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QIntfbScreen object.
|
||||
*/
|
||||
QIntfbScreen::~QIntfbScreen()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
static QIntfbScreen *connected = 0;
|
||||
|
||||
bool QIntfbScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
FBDriver *fbdev;
|
||||
|
||||
CheckSuccess(gh_FB_get_driver(0, &fbdev));
|
||||
CheckSuccess(gh_FB_init_device(fbdev, 0, &d_ptr->handle));
|
||||
CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
|
||||
|
||||
data = (uchar *)d_ptr->fbinfo.start;
|
||||
|
||||
d = d_ptr->fbinfo.bitsperpixel;
|
||||
switch (d) {
|
||||
case 1:
|
||||
setPixelFormat(QImage::Format_Mono);
|
||||
break;
|
||||
case 8:
|
||||
setPixelFormat(QImage::Format_Indexed8);
|
||||
break;
|
||||
case 12:
|
||||
setPixelFormat(QImage::Format_RGB444);
|
||||
break;
|
||||
case 15:
|
||||
setPixelFormat(QImage::Format_RGB555);
|
||||
break;
|
||||
case 16:
|
||||
setPixelFormat(QImage::Format_RGB16);
|
||||
break;
|
||||
case 18:
|
||||
setPixelFormat(QImage::Format_RGB666);
|
||||
break;
|
||||
case 24:
|
||||
setPixelFormat(QImage::Format_RGB888);
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
qt_set_generic_blit(this, 24,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
d_ptr->fbinfo.redoffset,
|
||||
d_ptr->fbinfo.greenoffset,
|
||||
d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset);
|
||||
#else
|
||||
qt_set_generic_blit(this, 24,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
16 - d_ptr->fbinfo.redoffset,
|
||||
16 - d_ptr->fbinfo.greenoffset,
|
||||
16 - d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case 32:
|
||||
setPixelFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
qt_set_generic_blit(this, 32,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
d_ptr->fbinfo.redoffset,
|
||||
d_ptr->fbinfo.greenoffset,
|
||||
d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset);
|
||||
#else
|
||||
qt_set_generic_blit(this, 32,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
24 - d_ptr->fbinfo.redoffset,
|
||||
24 - d_ptr->fbinfo.greenoffset,
|
||||
24 - d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
dw = w = d_ptr->fbinfo.width;
|
||||
dh = h = d_ptr->fbinfo.height;
|
||||
|
||||
/* assumes no padding */
|
||||
lstep = w * ((d + 7) >> 3);
|
||||
|
||||
mapsize = size = h * lstep;
|
||||
|
||||
/* default values */
|
||||
int dpi = 72;
|
||||
physWidth = qRound(dw * 25.4 / dpi);
|
||||
physHeight = qRound(dh * 25.4 / dpi);
|
||||
|
||||
qDebug("Connected to INTEGRITYfb server: %d x %d x %d %dx%dmm (%dx%ddpi)",
|
||||
w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
|
||||
|
||||
|
||||
QWSServer::setDefaultMouse("integrity");
|
||||
QWSServer::setDefaultKeyboard("integrity");
|
||||
|
||||
connected = this;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QIntfbScreen::disconnect()
|
||||
{
|
||||
connected = 0;
|
||||
}
|
||||
|
||||
bool QIntfbScreen::initDevice()
|
||||
{
|
||||
|
||||
CheckSuccess(gh_FB_set_info(d_ptr->handle, &d_ptr->fbinfo, false));
|
||||
CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
|
||||
data = (uchar *)d_ptr->fbinfo.start;
|
||||
d = d_ptr->fbinfo.bitsperpixel;
|
||||
dw = w = d_ptr->fbinfo.width;
|
||||
dh = h = d_ptr->fbinfo.height;
|
||||
mapsize = d_ptr->fbinfo.length;
|
||||
/* assumes no padding */
|
||||
lstep = w * ((d + 7) >> 3);
|
||||
|
||||
mapsize = size = h * lstep;
|
||||
|
||||
data = (uchar *)d_ptr->fbinfo.start;
|
||||
|
||||
d = d_ptr->fbinfo.bitsperpixel;
|
||||
switch (d) {
|
||||
case 1:
|
||||
setPixelFormat(QImage::Format_Mono);
|
||||
break;
|
||||
case 8:
|
||||
setPixelFormat(QImage::Format_Indexed8);
|
||||
break;
|
||||
case 12:
|
||||
setPixelFormat(QImage::Format_RGB444);
|
||||
break;
|
||||
case 15:
|
||||
setPixelFormat(QImage::Format_RGB555);
|
||||
break;
|
||||
case 16:
|
||||
setPixelFormat(QImage::Format_RGB16);
|
||||
break;
|
||||
case 18:
|
||||
setPixelFormat(QImage::Format_RGB666);
|
||||
break;
|
||||
case 24:
|
||||
setPixelFormat(QImage::Format_RGB888);
|
||||
break;
|
||||
case 32:
|
||||
setPixelFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
break;
|
||||
}
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
qt_set_generic_blit(this, d,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
24 - d_ptr->fbinfo.redoffset,
|
||||
24 - d_ptr->fbinfo.greenoffset,
|
||||
24 - d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
|
||||
#else
|
||||
qt_set_generic_blit(this, d,
|
||||
d_ptr->fbinfo.redbits,
|
||||
d_ptr->fbinfo.greenbits,
|
||||
d_ptr->fbinfo.bluebits,
|
||||
d_ptr->fbinfo.alphabits,
|
||||
d_ptr->fbinfo.redoffset,
|
||||
d_ptr->fbinfo.greenoffset,
|
||||
d_ptr->fbinfo.blueoffset,
|
||||
d_ptr->fbinfo.alphaoffset);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
QScreenCursor::initSoftwareCursor();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void QIntfbScreen::shutdownDevice()
|
||||
{
|
||||
gh_FB_close(d_ptr->handle);
|
||||
}
|
||||
|
||||
void QIntfbScreen::setMode(int ,int ,int)
|
||||
{
|
||||
}
|
||||
|
||||
// save the state of the graphics card
|
||||
// This is needed so that e.g. we can restore the palette when switching
|
||||
// between linux virtual consoles.
|
||||
void QIntfbScreen::save()
|
||||
{
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
// restore the state of the graphics card.
|
||||
void QIntfbScreen::restore()
|
||||
{
|
||||
}
|
||||
void QIntfbScreen::setDirty(const QRect& rect)
|
||||
{
|
||||
FBRect fbrect;
|
||||
fbrect.dx = rect.x();
|
||||
fbrect.dy = rect.y();
|
||||
fbrect.width = rect.width();
|
||||
fbrect.height = rect.height();
|
||||
gh_FB_expose(d_ptr->handle, &fbrect);
|
||||
}
|
||||
|
||||
void QIntfbScreen::setBrightness(int b)
|
||||
{
|
||||
if (connected) {
|
||||
}
|
||||
}
|
||||
|
||||
void QIntfbScreen::blank(bool on)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_INTEGRITYFB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -1,83 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENINTEGRITYFB_QWS_H
|
||||
#define QSCREENINTEGRITYFB_QWS_H
|
||||
|
||||
#include <QtGui/qscreen_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_INTEGRITYFB
|
||||
|
||||
class QIntfbScreenPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QIntfbScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
explicit QIntfbScreen(int display_id);
|
||||
virtual ~QIntfbScreen();
|
||||
virtual bool initDevice();
|
||||
virtual bool connect(const QString &displaySpec);
|
||||
virtual void disconnect();
|
||||
virtual void shutdownDevice();
|
||||
virtual void save();
|
||||
virtual void restore();
|
||||
virtual void setMode(int nw,int nh,int nd);
|
||||
virtual void setDirty(const QRect& r);
|
||||
virtual void blank(bool);
|
||||
static void setBrightness(int b);
|
||||
|
||||
private:
|
||||
QIntfbScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_INTEGRITYFB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENINTEGRITYFB_QWS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,135 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENLINUXFB_QWS_H
|
||||
#define QSCREENLINUXFB_QWS_H
|
||||
|
||||
#include <QtGui/qscreen_qws.h>
|
||||
|
||||
struct fb_cmap;
|
||||
struct fb_var_screeninfo;
|
||||
struct fb_fix_screeninfo;
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_LINUXFB
|
||||
|
||||
class QLinuxFb_Shared
|
||||
{
|
||||
public:
|
||||
volatile int lastop;
|
||||
volatile int optype;
|
||||
volatile int fifocount; // Accel drivers only
|
||||
volatile int fifomax;
|
||||
volatile int forecol; // Foreground colour caching
|
||||
volatile unsigned int buffer_offset; // Destination
|
||||
volatile int linestep;
|
||||
volatile int cliptop; // Clip rectangle
|
||||
volatile int clipleft;
|
||||
volatile int clipright;
|
||||
volatile int clipbottom;
|
||||
volatile unsigned int rop;
|
||||
|
||||
};
|
||||
|
||||
class QLinuxFbScreenPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QLinuxFbScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
explicit QLinuxFbScreen(int display_id);
|
||||
virtual ~QLinuxFbScreen();
|
||||
|
||||
virtual bool initDevice();
|
||||
virtual bool connect(const QString &displaySpec);
|
||||
|
||||
virtual bool useOffscreen();
|
||||
|
||||
enum DriverTypes { GenericDriver, EInk8Track };
|
||||
|
||||
virtual void disconnect();
|
||||
virtual void shutdownDevice();
|
||||
virtual void setMode(int,int,int);
|
||||
virtual void save();
|
||||
virtual void restore();
|
||||
virtual void blank(bool on);
|
||||
virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
|
||||
virtual uchar * cache(int);
|
||||
virtual void uncache(uchar *);
|
||||
virtual int sharedRamSize(void *);
|
||||
virtual void setDirty(const QRect&);
|
||||
|
||||
QLinuxFb_Shared * shared;
|
||||
|
||||
protected:
|
||||
|
||||
void deleteEntry(uchar *);
|
||||
|
||||
bool canaccel;
|
||||
int dataoffset;
|
||||
int cacheStart;
|
||||
|
||||
virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo);
|
||||
static void clearCache(QScreen *instance, int);
|
||||
|
||||
private:
|
||||
|
||||
void delete_entry(int);
|
||||
void insert_entry(int,int,int);
|
||||
void setupOffScreen();
|
||||
void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo);
|
||||
void setPixelFormat(struct fb_var_screeninfo);
|
||||
|
||||
QLinuxFbScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_LINUXFB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENLINUXFB_QWS_H
|
@ -1,486 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qscreenmulti_qws_p.h"
|
||||
|
||||
#ifndef QT_NO_QWS_MULTISCREEN
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qwidget.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
|
||||
class QMultiScreenCursor : public QScreenCursor
|
||||
{
|
||||
public:
|
||||
QMultiScreenCursor() : currentCursor(qt_screencursor) { enable = false; }
|
||||
~QMultiScreenCursor() { qt_screencursor = 0; }
|
||||
|
||||
void set(const QImage &image, int hotx, int hoty);
|
||||
void move(int x, int y);
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void addCursor(QScreenCursor *cursor);
|
||||
|
||||
private:
|
||||
void setCurrentCursor(QScreenCursor *newCursor);
|
||||
|
||||
QScreenCursor *currentCursor;
|
||||
QList<QScreenCursor*> cursors;
|
||||
};
|
||||
|
||||
void QMultiScreenCursor::set(const QImage &image, int hotx, int hoty)
|
||||
{
|
||||
QScreenCursor::set(image, hotx, hoty);
|
||||
if (currentCursor)
|
||||
currentCursor->set(image, hotx, hoty);
|
||||
}
|
||||
|
||||
void QMultiScreenCursor::setCurrentCursor(QScreenCursor *newCursor)
|
||||
{
|
||||
*((QScreenCursor*)this) = *newCursor;
|
||||
currentCursor = newCursor;
|
||||
}
|
||||
|
||||
// XXX: this is a mess!
|
||||
void QMultiScreenCursor::move(int x, int y)
|
||||
{
|
||||
const int oldIndex = qt_screen->subScreenIndexAt(pos);
|
||||
QScreenCursor::move(x, y); // updates pos
|
||||
const int newIndex = qt_screen->subScreenIndexAt(pos);
|
||||
|
||||
if (!currentCursor && oldIndex != -1)
|
||||
setCurrentCursor(cursors.at(oldIndex));
|
||||
QScreenCursor *oldCursor = currentCursor;
|
||||
|
||||
if (oldIndex != -1) {
|
||||
const QScreen *oldScreen = qt_screen->subScreens().at(oldIndex);
|
||||
if (newIndex == -1 || oldScreen->region().contains(pos)) {
|
||||
oldCursor->move(x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (newIndex != -1) {
|
||||
QScreenCursor *newCursor = cursors.at(newIndex);
|
||||
newCursor->set(cursor, hotspot.x(), hotspot.y());
|
||||
|
||||
if (oldCursor) {
|
||||
if (oldCursor->isVisible())
|
||||
newCursor->show();
|
||||
oldCursor->hide();
|
||||
}
|
||||
|
||||
newCursor->move(x, y);
|
||||
|
||||
setCurrentCursor(newCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void QMultiScreenCursor::show()
|
||||
{
|
||||
if (currentCursor)
|
||||
currentCursor->show();
|
||||
}
|
||||
|
||||
void QMultiScreenCursor::hide()
|
||||
{
|
||||
if (currentCursor)
|
||||
currentCursor->hide();
|
||||
}
|
||||
|
||||
void QMultiScreenCursor::addCursor(QScreenCursor *cursor)
|
||||
{
|
||||
cursors.append(cursor);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class QMultiScreenPrivate
|
||||
{
|
||||
public:
|
||||
QMultiScreenPrivate()
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
: cursor(0)
|
||||
#endif
|
||||
{}
|
||||
~QMultiScreenPrivate()
|
||||
{
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
delete cursor;
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<QScreen*> screens;
|
||||
QRegion region;
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
QMultiScreenCursor *cursor;
|
||||
#endif
|
||||
};
|
||||
|
||||
QMultiScreen::QMultiScreen(int displayId)
|
||||
: QScreen(displayId, MultiClass), d_ptr(new QMultiScreenPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
QMultiScreen::~QMultiScreen()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
bool QMultiScreen::initDevice()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
d_ptr->cursor = new QMultiScreenCursor;
|
||||
#endif
|
||||
|
||||
const int n = d_ptr->screens.count();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *s = d_ptr->screens.at(i);
|
||||
ok = s->initDevice() && ok;
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
d_ptr->cursor->addCursor(qt_screencursor); // XXX
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
// XXX
|
||||
qt_screencursor = d_ptr->cursor;
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int getDisplayId(const QString &spec)
|
||||
{
|
||||
QRegExp regexp(QLatin1String(":(\\d+)\\b"));
|
||||
if (regexp.lastIndexIn(spec) != -1) {
|
||||
const QString capture = regexp.cap(1);
|
||||
return capture.toInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static QPoint filterDisplayOffset(QString &spec)
|
||||
{
|
||||
QRegExp regexp(QLatin1String(":offset=(\\d+),(\\d+)\\b"));
|
||||
if (regexp.indexIn(spec) == -1)
|
||||
return QPoint();
|
||||
|
||||
const int x = regexp.cap(1).toInt();
|
||||
const int y = regexp.cap(2).toInt();
|
||||
spec.remove(regexp.pos(0), regexp.matchedLength());
|
||||
return QPoint(x, y);
|
||||
}
|
||||
|
||||
bool QMultiScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
QString dSpec = displaySpec;
|
||||
if (dSpec.startsWith(QLatin1String("Multi:"), Qt::CaseInsensitive))
|
||||
dSpec = dSpec.mid(QString::fromLatin1("Multi:").size());
|
||||
|
||||
const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
|
||||
if (dSpec.endsWith(displayIdSpec))
|
||||
dSpec = dSpec.left(dSpec.size() - displayIdSpec.size());
|
||||
|
||||
QStringList specs = dSpec.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
foreach (QString spec, specs) {
|
||||
const int id = getDisplayId(spec);
|
||||
if (spec.startsWith("vnc:", Qt::CaseInsensitive)) {
|
||||
spec.append(":noDisablePainting");
|
||||
}
|
||||
const QPoint offset = filterDisplayOffset(spec);
|
||||
QScreen *s = qt_get_screen(id, spec.toLatin1().constData());
|
||||
s->setOffset(offset);
|
||||
addSubScreen(s);
|
||||
}
|
||||
|
||||
QScreen *firstScreen = d_ptr->screens.at(0);
|
||||
Q_ASSERT(firstScreen);
|
||||
|
||||
// XXX
|
||||
QScreen::d = firstScreen->depth();
|
||||
|
||||
QScreen::lstep = 0;
|
||||
QScreen::data = 0;
|
||||
QScreen::size = 0;
|
||||
|
||||
QScreen::w = d_ptr->region.boundingRect().width();
|
||||
QScreen::h = d_ptr->region.boundingRect().height();
|
||||
|
||||
QScreen::dw = QScreen::w;
|
||||
QScreen::dh = QScreen::h;
|
||||
|
||||
// XXX - Extend the physical size based on the first screen
|
||||
// to encompass all screens, so that code that uses the multi
|
||||
// screen to calculate dpi values will get the right numbers.
|
||||
QScreen::physWidth = firstScreen->physicalWidth() * w / firstScreen->width();
|
||||
QScreen::physHeight = firstScreen->physicalHeight() * h / firstScreen->height();
|
||||
|
||||
// XXXXX
|
||||
qt_screen = this;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QMultiScreen::disconnect()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->disconnect();
|
||||
}
|
||||
|
||||
void QMultiScreen::shutdownDevice()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->shutdownDevice();
|
||||
}
|
||||
|
||||
void QMultiScreen::setMode(int, int, int)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool QMultiScreen::supportsDepth(int) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QMultiScreen::save()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->save();
|
||||
}
|
||||
|
||||
void QMultiScreen::restore()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->restore();
|
||||
}
|
||||
|
||||
void QMultiScreen::blank(bool on)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->blank(on);
|
||||
}
|
||||
|
||||
bool QMultiScreen::onCard(const unsigned char *ptr) const
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
if (d_ptr->screens.at(i)->onCard(ptr))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QMultiScreen::onCard(const unsigned char *ptr, ulong &offset) const
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
if (d_ptr->screens.at(i)->onCard(ptr, offset))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QMultiScreen::isInterlaced() const
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
if (d_ptr->screens.at(i)->isInterlaced())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int QMultiScreen::memoryNeeded(const QString &string)
|
||||
{
|
||||
int total = 0;
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
total += d_ptr->screens.at(i)->memoryNeeded(string);
|
||||
return total;
|
||||
}
|
||||
|
||||
int QMultiScreen::sharedRamSize(void *arg)
|
||||
{
|
||||
int total = 0;
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
total += d_ptr->screens.at(i)->sharedRamSize(arg);
|
||||
return total;
|
||||
}
|
||||
|
||||
void QMultiScreen::haltUpdates()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->haltUpdates();
|
||||
}
|
||||
|
||||
void QMultiScreen::resumeUpdates()
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i)
|
||||
d_ptr->screens.at(i)->resumeUpdates();
|
||||
}
|
||||
|
||||
void QMultiScreen::exposeRegion(QRegion region, int changing)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
const QRegion r = region & screen->region();
|
||||
if (r.isEmpty())
|
||||
continue;
|
||||
screen->exposeRegion(r, changing);
|
||||
}
|
||||
}
|
||||
|
||||
void QMultiScreen::solidFill(const QColor &color, const QRegion ®ion)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
const QRegion r = region & screen->region();
|
||||
if (r.isEmpty())
|
||||
continue;
|
||||
screen->solidFill(color, r);
|
||||
}
|
||||
}
|
||||
|
||||
void QMultiScreen::blit(const QImage &img, const QPoint &topLeft,
|
||||
const QRegion ®ion)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
const QRegion r = region & screen->region();
|
||||
if (r.isEmpty())
|
||||
continue;
|
||||
screen->blit(img, topLeft, r);
|
||||
}
|
||||
}
|
||||
|
||||
void QMultiScreen::blit(QWSWindow *bs, const QRegion &clip)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
const QRegion r = clip & screen->region();
|
||||
if (r.isEmpty())
|
||||
continue;
|
||||
screen->blit(bs, r);
|
||||
}
|
||||
}
|
||||
|
||||
void QMultiScreen::setDirty(const QRect &rect)
|
||||
{
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
const QRegion r = screen->region() & rect;
|
||||
if (r.isEmpty())
|
||||
continue;
|
||||
screen->setDirty(r.boundingRect());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QWSWindowSurface* QMultiScreen::createSurface(const QString &key) const
|
||||
{
|
||||
QWSWindowSurface* surf = 0;
|
||||
const int n = d_ptr->screens.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QScreen *screen = d_ptr->screens.at(i);
|
||||
surf = screen->createSurface(key);
|
||||
if (surf)
|
||||
break;
|
||||
}
|
||||
return surf;
|
||||
}
|
||||
|
||||
|
||||
QWSWindowSurface* QMultiScreen::createSurface(QWidget *widget) const
|
||||
{
|
||||
const QPoint midpoint = (widget->frameGeometry().topLeft()
|
||||
+ widget->frameGeometry().bottomRight()) / 2;
|
||||
int index = subScreenIndexAt(midpoint);
|
||||
if (index == -1)
|
||||
index = 0; // XXX
|
||||
return d_ptr->screens.at(index)->createSurface(widget);
|
||||
}
|
||||
|
||||
QList<QScreen*> QMultiScreen::subScreens() const
|
||||
{
|
||||
return d_ptr->screens;
|
||||
}
|
||||
|
||||
QRegion QMultiScreen::region() const
|
||||
{
|
||||
return d_ptr->region;
|
||||
}
|
||||
|
||||
void QMultiScreen::addSubScreen(QScreen *screen)
|
||||
{
|
||||
d_ptr->screens.append(screen);
|
||||
d_ptr->region += screen->region();
|
||||
}
|
||||
|
||||
void QMultiScreen::removeSubScreen(QScreen *screen)
|
||||
{
|
||||
d_ptr->screens.removeAll(screen);
|
||||
d_ptr->region -= screen->region();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_MULTISCREEN
|
@ -1,114 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMULTISCREEN_QWS_P_H
|
||||
#define QMULTISCREEN_QWS_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 <qscreen_qws.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_QWS_MULTISCREEN
|
||||
|
||||
class QMultiScreenPrivate;
|
||||
|
||||
class QMultiScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
QMultiScreen(int displayId);
|
||||
~QMultiScreen();
|
||||
bool initDevice();
|
||||
bool connect(const QString &displaySpec);
|
||||
void disconnect();
|
||||
void shutdownDevice();
|
||||
void setMode(int,int,int);
|
||||
bool supportsDepth(int) const;
|
||||
|
||||
void save();
|
||||
void restore();
|
||||
void blank(bool on);
|
||||
|
||||
bool onCard(const unsigned char *) const;
|
||||
bool onCard(const unsigned char *, ulong& out_offset) const;
|
||||
|
||||
bool isInterlaced() const;
|
||||
|
||||
int memoryNeeded(const QString&);
|
||||
int sharedRamSize(void *);
|
||||
|
||||
void haltUpdates();
|
||||
void resumeUpdates();
|
||||
|
||||
void exposeRegion(QRegion r, int changing);
|
||||
|
||||
void blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion);
|
||||
void solidFill(const QColor &color, const QRegion ®ion);
|
||||
void blit(QWSWindow *bs, const QRegion &clip);
|
||||
void setDirty(const QRect&);
|
||||
|
||||
QWSWindowSurface* createSurface(QWidget *widget) const;
|
||||
QWSWindowSurface* createSurface(const QString &key) const;
|
||||
|
||||
QList<QScreen*> subScreens() const;
|
||||
QRegion region() const;
|
||||
|
||||
private:
|
||||
void addSubScreen(QScreen *screen);
|
||||
void removeSubScreen(QScreen *screen);
|
||||
|
||||
QMultiScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QT_NO_QWS_MULTISCREEN
|
||||
#endif // QMULTISCREEN_QWS_P_H
|
@ -1,635 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qscreenproxy_qws.h>
|
||||
|
||||
#ifndef QT_NO_QWS_PROXYSCREEN
|
||||
|
||||
#include <qregexp.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
|
||||
/*!
|
||||
\class QProxyScreenCursor
|
||||
\since 4.5
|
||||
\ingroup qws
|
||||
\brief The QProxyScreenCursor class provides a generic interface to
|
||||
QScreenCursor implementations.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a proxy screen cursor.
|
||||
*/
|
||||
QProxyScreenCursor::QProxyScreenCursor()
|
||||
: QScreenCursor(), realCursor(0), d_ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the proxy screen cursor.
|
||||
*/
|
||||
QProxyScreenCursor::~QProxyScreenCursor()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the real screen cursor to be used for the proxy screen cursor to
|
||||
the \a cursor specified.
|
||||
|
||||
\sa screenCursor()
|
||||
*/
|
||||
void QProxyScreenCursor::setScreenCursor(QScreenCursor *cursor)
|
||||
{
|
||||
realCursor = cursor;
|
||||
configure();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the real screen cursor used by the proxy screen cursor.
|
||||
|
||||
\sa setScreenCursor()
|
||||
*/
|
||||
QScreenCursor* QProxyScreenCursor::screenCursor() const
|
||||
{
|
||||
return realCursor;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreenCursor::set(const QImage &image, int hotx, int hoty)
|
||||
{
|
||||
if (realCursor) {
|
||||
hotspot = QPoint(hotx, hoty);
|
||||
cursor = image;
|
||||
size = image.size();
|
||||
realCursor->set(image, hotx, hoty);
|
||||
} else {
|
||||
QScreenCursor::set(image, hotx, hoty);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreenCursor::move(int x, int y)
|
||||
{
|
||||
if (realCursor) {
|
||||
pos = QPoint(x, y);
|
||||
realCursor->move(x, y);
|
||||
} else {
|
||||
QScreenCursor::move(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreenCursor::show()
|
||||
{
|
||||
if (realCursor) {
|
||||
realCursor->show();
|
||||
enable = true;
|
||||
} else {
|
||||
QScreenCursor::show();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreenCursor::hide()
|
||||
{
|
||||
if (realCursor) {
|
||||
realCursor->hide();
|
||||
enable = false;
|
||||
} else {
|
||||
QScreenCursor::hide();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QProxyScreenCursor::configure()
|
||||
{
|
||||
if (!realCursor)
|
||||
return;
|
||||
|
||||
cursor = realCursor->cursor;
|
||||
size = realCursor->size;
|
||||
pos = realCursor->pos;
|
||||
hotspot = realCursor->hotspot;
|
||||
enable = realCursor->enable;
|
||||
hwaccel = realCursor->hwaccel;
|
||||
supportsAlpha = realCursor->supportsAlpha;
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_CURSOR
|
||||
|
||||
/*!
|
||||
\class QProxyScreen
|
||||
\ingroup qws
|
||||
\brief The QProxyScreen class provides a generic interface to QScreen implementations.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QProxyScreen::QProxyScreen(int displayId, ClassId classId)
|
||||
|
||||
Constructs a proxy screen with the given \a displayId and \a classId.
|
||||
*/
|
||||
QProxyScreen::QProxyScreen(int displayId, QScreen::ClassId classId)
|
||||
: QScreen(displayId, classId), realScreen(0), d_ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the proxy screen.
|
||||
*/
|
||||
QProxyScreen::~QProxyScreen()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the real \a screen to be used by the proxy screen.
|
||||
|
||||
\sa screen()
|
||||
*/
|
||||
void QProxyScreen::setScreen(QScreen *screen)
|
||||
{
|
||||
realScreen = screen;
|
||||
configure();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the real screen used by the proxy screen.
|
||||
|
||||
\sa setScreen()
|
||||
*/
|
||||
QScreen* QProxyScreen::screen() const
|
||||
{
|
||||
return realScreen;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QProxyScreen::configure()
|
||||
{
|
||||
if (!realScreen)
|
||||
return;
|
||||
|
||||
d = realScreen->depth();
|
||||
w = realScreen->width();
|
||||
h = realScreen->height();
|
||||
dw = realScreen->deviceWidth();
|
||||
dh = realScreen->deviceHeight();
|
||||
lstep = realScreen->linestep();
|
||||
data = realScreen->base();
|
||||
lstep = realScreen->linestep();
|
||||
size = realScreen->screenSize();
|
||||
physWidth = realScreen->physicalWidth();
|
||||
physHeight = realScreen->physicalHeight();
|
||||
pixeltype = realScreen->pixelType();
|
||||
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
||||
setFrameBufferLittleEndian(realScreen->frameBufferLittleEndian());
|
||||
#endif
|
||||
|
||||
setOffset(realScreen->offset());
|
||||
setPixelFormat(realScreen->pixelFormat());
|
||||
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
setSupportsBlitInClients(realScreen->supportsBlitInClients());
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Returns the display ID that corresponds to the given \a spec.
|
||||
*/
|
||||
static int getDisplayId(const QString &spec)
|
||||
{
|
||||
QRegExp regexp(QLatin1String(":(\\d+)\\b"));
|
||||
if (regexp.lastIndexIn(spec) != -1) {
|
||||
const QString capture = regexp.cap(1);
|
||||
return capture.toInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
const int id = getDisplayId(displaySpec);
|
||||
realScreen = qt_get_screen(id, displaySpec.toLatin1().constData());
|
||||
configure();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::exposeRegion(QRegion r, int changing)
|
||||
{
|
||||
if (!realScreen) {
|
||||
QScreen::exposeRegion(r, changing);
|
||||
return;
|
||||
}
|
||||
|
||||
realScreen->exposeRegion(r, changing);
|
||||
r &= realScreen->region();
|
||||
|
||||
const QVector<QRect> rects = r.rects();
|
||||
for (int i = 0; i < rects.size(); ++i)
|
||||
setDirty(rects.at(i));
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::blit(const QImage &image, const QPoint &topLeft,
|
||||
const QRegion ®ion)
|
||||
{
|
||||
if (!realScreen) {
|
||||
QScreen::blit(image, topLeft, region);
|
||||
return;
|
||||
}
|
||||
|
||||
realScreen->blit(image, topLeft, region);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::solidFill(const QColor &color, const QRegion ®ion)
|
||||
{
|
||||
if (!realScreen) {
|
||||
QScreen::solidFill(color, region);
|
||||
return;
|
||||
}
|
||||
realScreen->solidFill(color, region);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QSize QProxyScreen::mapToDevice(const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapToDevice(s);
|
||||
|
||||
return realScreen->mapToDevice(s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QSize QProxyScreen::mapFromDevice(const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapFromDevice(s);
|
||||
|
||||
return realScreen->mapFromDevice(s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QPoint QProxyScreen::mapToDevice(const QPoint &p, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapToDevice(p, s);
|
||||
|
||||
return realScreen->mapToDevice(p, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QPoint QProxyScreen::mapFromDevice(const QPoint &p, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapFromDevice(p, s);
|
||||
|
||||
return realScreen->mapFromDevice(p, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRect QProxyScreen::mapToDevice(const QRect &r, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapToDevice(r, s);
|
||||
|
||||
return realScreen->mapToDevice(r, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRect QProxyScreen::mapFromDevice(const QRect &r, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapFromDevice(r, s);
|
||||
|
||||
return realScreen->mapFromDevice(r, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QProxyScreen::mapToDevice(const QRegion &r, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapToDevice(r, s);
|
||||
|
||||
return realScreen->mapToDevice(r, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QProxyScreen::mapFromDevice(const QRegion &r, const QSize &s) const
|
||||
{
|
||||
if (!realScreen)
|
||||
return QScreen::mapFromDevice(r, s);
|
||||
|
||||
return realScreen->mapFromDevice(r, s);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::disconnect()
|
||||
{
|
||||
if (realScreen) {
|
||||
realScreen->disconnect();
|
||||
delete realScreen;
|
||||
realScreen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
bool QProxyScreen::initDevice()
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->initDevice();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::shutdownDevice()
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->shutdownDevice();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::setMode(int w,int h, int d)
|
||||
{
|
||||
if (realScreen) {
|
||||
realScreen->setMode(w, h, d);
|
||||
} else {
|
||||
QScreen::dw = QScreen::w = w;
|
||||
QScreen::dh = QScreen::h = h;
|
||||
QScreen::d = d;
|
||||
}
|
||||
configure();
|
||||
exposeRegion(region(), 0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::supportsDepth(int depth) const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->supportsDepth(depth);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::save()
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->save();
|
||||
QScreen::save();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::restore()
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->restore();
|
||||
QScreen::restore();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::blank(bool on)
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->blank(on);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::onCard(const unsigned char *ptr) const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->onCard(ptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::onCard(const unsigned char *ptr, ulong &offset) const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->onCard(ptr, offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::isInterlaced() const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->isInterlaced();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QProxyScreen::isTransformed() const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->isTransformed();
|
||||
return QScreen::isTransformed();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
int QProxyScreen::transformOrientation() const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->transformOrientation();
|
||||
return QScreen::transformOrientation();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
int QProxyScreen::memoryNeeded(const QString &str)
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->memoryNeeded(str);
|
||||
else
|
||||
return QScreen::memoryNeeded(str);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
int QProxyScreen::sharedRamSize(void *ptr)
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->sharedRamSize(ptr);
|
||||
else
|
||||
return QScreen::sharedRamSize(ptr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QProxyScreen::haltUpdates()
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->haltUpdates();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QProxyScreen::resumeUpdates()
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->resumeUpdates();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QProxyScreen::setDirty(const QRect &rect)
|
||||
{
|
||||
if (realScreen)
|
||||
realScreen->setDirty(rect);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QWSWindowSurface* QProxyScreen::createSurface(QWidget *widget) const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->createSurface(widget);
|
||||
|
||||
return QScreen::createSurface(widget);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QWSWindowSurface* QProxyScreen::createSurface(const QString &key) const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->createSurface(key);
|
||||
|
||||
return QScreen::createSurface(key);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QList<QScreen*> QProxyScreen::subScreens() const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->subScreens();
|
||||
|
||||
return QScreen::subScreens();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QProxyScreen::region() const
|
||||
{
|
||||
if (realScreen)
|
||||
return realScreen->region();
|
||||
else
|
||||
return QScreen::region();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_PROXYSCREEN
|
@ -1,153 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPROXYSCREEN_QWS_H
|
||||
#define QPROXYSCREEN_QWS_H
|
||||
|
||||
#include <QtGui/qscreen_qws.h>
|
||||
|
||||
#ifndef QT_NO_QWS_PROXYSCREEN
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QProxyScreenPrivate;
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
|
||||
class QProxyScreenCursorPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QProxyScreenCursor : public QScreenCursor
|
||||
{
|
||||
public:
|
||||
QProxyScreenCursor();
|
||||
~QProxyScreenCursor();
|
||||
|
||||
void setScreenCursor(QScreenCursor *cursor);
|
||||
QScreenCursor* screenCursor() const;
|
||||
|
||||
void set(const QImage &image, int hotx, int hoty);
|
||||
void move(int x, int y);
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
private:
|
||||
void configure();
|
||||
|
||||
QScreenCursor *realCursor;
|
||||
QProxyScreenCursorPrivate *d_ptr;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_CURSOR
|
||||
|
||||
class Q_GUI_EXPORT QProxyScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
QProxyScreen(int display_id, ClassId = ProxyClass);
|
||||
~QProxyScreen();
|
||||
|
||||
void setScreen(QScreen *screen);
|
||||
QScreen *screen() const;
|
||||
|
||||
QSize mapToDevice(const QSize &s) const;
|
||||
QSize mapFromDevice(const QSize &s) const;
|
||||
|
||||
QPoint mapToDevice(const QPoint &, const QSize &) const;
|
||||
QPoint mapFromDevice(const QPoint &, const QSize &) const;
|
||||
|
||||
QRect mapToDevice(const QRect &, const QSize &) const;
|
||||
QRect mapFromDevice(const QRect &, const QSize &) const;
|
||||
|
||||
QRegion mapToDevice(const QRegion &, const QSize &) const;
|
||||
QRegion mapFromDevice(const QRegion &, const QSize &) const;
|
||||
|
||||
bool connect(const QString &displaySpec);
|
||||
bool initDevice();
|
||||
void shutdownDevice();
|
||||
void disconnect();
|
||||
|
||||
void setMode(int width, int height, int depth);
|
||||
bool supportsDepth(int) const;
|
||||
|
||||
void save();
|
||||
void restore();
|
||||
void blank(bool on);
|
||||
|
||||
bool onCard(const unsigned char *) const;
|
||||
bool onCard(const unsigned char *, ulong& out_offset) const;
|
||||
|
||||
bool isInterlaced() const;
|
||||
bool isTransformed() const;
|
||||
int transformOrientation() const;
|
||||
|
||||
int memoryNeeded(const QString&);
|
||||
int sharedRamSize(void *);
|
||||
|
||||
void haltUpdates();
|
||||
void resumeUpdates();
|
||||
|
||||
void exposeRegion(QRegion r, int changing);
|
||||
void blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion);
|
||||
void solidFill(const QColor &color, const QRegion ®ion);
|
||||
void setDirty(const QRect&);
|
||||
|
||||
QWSWindowSurface* createSurface(QWidget *widget) const;
|
||||
QWSWindowSurface* createSurface(const QString &key) const;
|
||||
|
||||
QList<QScreen*> subScreens() const;
|
||||
QRegion region() const;
|
||||
|
||||
private:
|
||||
void configure();
|
||||
|
||||
QScreen *realScreen;
|
||||
QProxyScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QT_NO_QWS_PROXYSCREEN
|
||||
#endif // QPROXYSCREEN_QWS_H
|
@ -1,450 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qscreenqnx_qws.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#include <gf/gf.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// This struct holds all the pointers to QNX's internals
|
||||
struct QQnxScreenContext
|
||||
{
|
||||
inline QQnxScreenContext()
|
||||
: device(0), display(0), layer(0), hwSurface(0), memSurface(0), context(0)
|
||||
{}
|
||||
|
||||
gf_dev_t device;
|
||||
gf_dev_info_t deviceInfo;
|
||||
gf_display_t display;
|
||||
gf_display_info_t displayInfo;
|
||||
gf_layer_t layer;
|
||||
gf_surface_t hwSurface;
|
||||
gf_surface_t memSurface;
|
||||
gf_surface_info_t memSurfaceInfo;
|
||||
gf_context_t context;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QQnxScreen
|
||||
\preliminary
|
||||
\ingroup qws
|
||||
\since 4.6
|
||||
\internal
|
||||
|
||||
\brief The QQnxScreen class implements a screen driver
|
||||
for QNX io-display based devices.
|
||||
|
||||
Note - you never have to instanciate this class, the QScreenDriverFactory
|
||||
does that for us based on the \c{QWS_DISPLAY} environment variable.
|
||||
|
||||
To activate this driver, set \c{QWS_DISPLAY} to \c{qnx}.
|
||||
|
||||
Example:
|
||||
\c{QWS_DISPLAY=qnx; export QWS_DISPLAY}
|
||||
|
||||
By default, the main layer of the first display of the first device is used.
|
||||
If you have multiple graphic cards, multiple displays or multiple layers and
|
||||
don't want to connect to the default, you can override that with setting
|
||||
the corresponding options \c{device}, \c{display} or \c{layer} in the \c{QWS_DISPLAY} variable:
|
||||
|
||||
\c{QWS_DISPLAY=qnx:device=3:display=4:layer=5}
|
||||
|
||||
In addition, it is suggested to set the physical width and height of the display.
|
||||
QQnxScreen will use that information to compute the dots per inch (DPI) in order to render
|
||||
fonts correctly. If this informaiton is omitted, QQnxScreen defaults to 72 dpi.
|
||||
|
||||
\c{QWS_DISPLAY=qnx:mmWidth=120:mmHeight=80}
|
||||
|
||||
\c{mmWidth} and \c{mmHeight} are the physical width/height of the screen in millimeters.
|
||||
|
||||
\sa QScreen, QScreenDriverPlugin, {Running Qt for Embedded Linux Applications}{Running Applications}
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QQnxScreen object. The \a display_id argument
|
||||
identifies the Qt for Embedded Linux server to connect to.
|
||||
*/
|
||||
QQnxScreen::QQnxScreen(int display_id)
|
||||
: QScreen(display_id), d(new QQnxScreenContext)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QQnxScreen object.
|
||||
*/
|
||||
QQnxScreen::~QQnxScreen()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
bool QQnxScreen::initDevice()
|
||||
{
|
||||
// implement this if you have multiple processes that want to access the display
|
||||
// (not required if QT_NO_QWS_MULTIPROCESS is set)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Attaches to the named device \a name.
|
||||
*/
|
||||
static bool attachDevice(QQnxScreenContext * const d, const char *name)
|
||||
{
|
||||
int ret = gf_dev_attach(&d->device, name, &d->deviceInfo);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_dev_attach(%s) failed with error code %d", name, ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Attaches to the display at index \a displayIndex.
|
||||
*/
|
||||
static bool attachDisplay(QQnxScreenContext * const d, int displayIndex)
|
||||
{
|
||||
int ret = gf_display_attach(&d->display, d->device, displayIndex, &d->displayInfo);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_display_attach(%d) failed with error code %d",
|
||||
displayIndex, ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Attaches to the layer \a layerIndex.
|
||||
*/
|
||||
static bool attachLayer(QQnxScreenContext * const d, int layerIndex)
|
||||
{
|
||||
int ret = gf_layer_attach(&d->layer, d->display, layerIndex, 0);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_layer_attach(%d) failed with error code %d", layerIndex,
|
||||
ret);
|
||||
return false;
|
||||
}
|
||||
gf_layer_enable(d->layer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Creates a new hardware surface (usually on the Gfx card memory) with the dimensions \a w * \a h.
|
||||
*/
|
||||
static bool createHwSurface(QQnxScreenContext * const d, int w, int h)
|
||||
{
|
||||
int ret = gf_surface_create_layer(&d->hwSurface, &d->layer, 1, 0,
|
||||
w, h, GF_FORMAT_ARGB8888, 0, 0);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_surface_create_layer(%dx%d) failed with error code %d",
|
||||
w, h, ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
gf_layer_set_surfaces(d->layer, &d->hwSurface, 1);
|
||||
|
||||
ret = gf_layer_update(d->layer, 0);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_layer_update() failed with error code %d\n", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
Creates an in-memory, linear accessible surface of dimensions \a w * \a h.
|
||||
This is the main surface that QWS blits to.
|
||||
*/
|
||||
static bool createMemSurface(QQnxScreenContext * const d, int w, int h)
|
||||
{
|
||||
// Note: gf_surface_attach() could also be used, so we'll create the buffer
|
||||
// and let the surface point to it. Here, we use surface_create instead.
|
||||
|
||||
int ret = gf_surface_create(&d->memSurface, d->device, w, h,
|
||||
GF_FORMAT_ARGB8888, 0,
|
||||
GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
|
||||
| GF_SURFACE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
|
||||
w, h, ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
|
||||
|
||||
if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
|
||||
qWarning("QQnxScreen: gf_surface_get_info() failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* \internal
|
||||
Creates a QNX gf context and sets our memory surface on it.
|
||||
*/
|
||||
static bool createContext(QQnxScreenContext * const d)
|
||||
{
|
||||
int ret = gf_context_create(&d->context);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = gf_context_set_surface(d->context, d->memSurface);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
Connects to QNX's io-display based device based on the \a displaySpec parameters
|
||||
from the \c{QWS_DISPLAY} environment variable. See the QQnxScreen class documentation
|
||||
for possible parameters.
|
||||
|
||||
\sa QQnxScreen
|
||||
*/
|
||||
bool QQnxScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
const QStringList params = displaySpec.split(QLatin1Char(':'), QString::SkipEmptyParts);
|
||||
|
||||
bool isOk = false;
|
||||
QRegExp deviceRegExp(QLatin1String("^device=(.+)$"));
|
||||
if (params.indexOf(deviceRegExp) != -1) {
|
||||
isOk = attachDevice(d, deviceRegExp.cap(1).toLocal8Bit().constData());
|
||||
} else {
|
||||
// no device specified - attach to device 0 (the default)
|
||||
isOk = attachDevice(d, GF_DEVICE_INDEX(0));
|
||||
}
|
||||
|
||||
if (!isOk)
|
||||
return false;
|
||||
|
||||
qDebug("QQnxScreen: Attached to Device, number of displays: %d", d->deviceInfo.ndisplays);
|
||||
|
||||
// default to display 0
|
||||
int displayIndex = 0;
|
||||
QRegExp displayRegexp(QLatin1String("^display=(\\d+)$"));
|
||||
if (params.indexOf(displayRegexp) != -1) {
|
||||
displayIndex = displayRegexp.cap(1).toInt();
|
||||
}
|
||||
|
||||
if (!attachDisplay(d, displayIndex))
|
||||
return false;
|
||||
|
||||
qDebug("QQnxScreen: Attached to Display %d, resolution %dx%d, refresh %d Hz",
|
||||
displayIndex, d->displayInfo.xres, d->displayInfo.yres,
|
||||
d->displayInfo.refresh);
|
||||
|
||||
|
||||
// default to main_layer_index from the displayInfo struct
|
||||
int layerIndex = 0;
|
||||
QRegExp layerRegexp(QLatin1String("^layer=(\\d+)$"));
|
||||
if (params.indexOf(layerRegexp) != -1) {
|
||||
layerIndex = layerRegexp.cap(1).toInt();
|
||||
} else {
|
||||
layerIndex = d->displayInfo.main_layer_index;
|
||||
}
|
||||
|
||||
if (!attachLayer(d, layerIndex))
|
||||
return false;
|
||||
|
||||
// tell QWSDisplay the width and height of the display
|
||||
w = dw = d->displayInfo.xres;
|
||||
h = dh = d->displayInfo.yres;
|
||||
|
||||
// we only support 32 bit displays for now.
|
||||
QScreen::d = 32;
|
||||
|
||||
// assume 72 dpi as default, to calculate the physical dimensions if not specified
|
||||
const int defaultDpi = 72;
|
||||
|
||||
// Handle display physical size spec.
|
||||
QRegExp mmWidthRegexp(QLatin1String("^mmWidth=(\\d+)$"));
|
||||
if (params.indexOf(mmWidthRegexp) == -1) {
|
||||
physWidth = qRound(dw * 25.4 / defaultDpi);
|
||||
} else {
|
||||
physWidth = mmWidthRegexp.cap(1).toInt();
|
||||
}
|
||||
|
||||
QRegExp mmHeightRegexp(QLatin1String("^mmHeight=(\\d+)$"));
|
||||
if (params.indexOf(mmHeightRegexp) == -1) {
|
||||
physHeight = qRound(dh * 25.4 / defaultDpi);
|
||||
} else {
|
||||
physHeight = mmHeightRegexp.cap(1).toInt();
|
||||
}
|
||||
|
||||
// create a hardware surface with our dimensions. In the old days, it was possible
|
||||
// to get a pointer directly to the hw surface, so we could blit directly. Now, we
|
||||
// have to use one indirection more, because it's not guaranteed that the hw surface
|
||||
// is mappable into our process.
|
||||
if (!createHwSurface(d, w, h))
|
||||
return false;
|
||||
|
||||
// create an in-memory linear surface that is used by QWS. QWS will blit directly in here.
|
||||
if (!createMemSurface(d, w, h))
|
||||
return false;
|
||||
|
||||
// set the address of the in-memory buffer that QWS is blitting to
|
||||
data = d->memSurfaceInfo.vaddr;
|
||||
// set the line stepping
|
||||
lstep = d->memSurfaceInfo.stride;
|
||||
|
||||
// the overall size of the in-memory buffer is linestep * height
|
||||
size = mapsize = lstep * h;
|
||||
|
||||
// create a QNX drawing context
|
||||
if (!createContext(d))
|
||||
return false;
|
||||
|
||||
// we're always using a software cursor for now. Initialize it here.
|
||||
QScreenCursor::initSoftwareCursor();
|
||||
|
||||
// done, the driver should be connected to the display now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
void QQnxScreen::disconnect()
|
||||
{
|
||||
if (d->context)
|
||||
gf_context_free(d->context);
|
||||
|
||||
if (d->memSurface)
|
||||
gf_surface_free(d->memSurface);
|
||||
|
||||
if (d->hwSurface)
|
||||
gf_surface_free(d->hwSurface);
|
||||
|
||||
if (d->layer)
|
||||
gf_layer_detach(d->layer);
|
||||
|
||||
if (d->display)
|
||||
gf_display_detach(d->display);
|
||||
|
||||
if (d->device)
|
||||
gf_dev_detach(d->device);
|
||||
|
||||
d->memSurface = 0;
|
||||
d->hwSurface = 0;
|
||||
d->context = 0;
|
||||
d->layer = 0;
|
||||
d->display = 0;
|
||||
d->device = 0;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
void QQnxScreen::shutdownDevice()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! \reimp
|
||||
QQnxScreen doesn't support setting the mode, use io-display instead.
|
||||
*/
|
||||
void QQnxScreen::setMode(int,int,int)
|
||||
{
|
||||
qWarning("QQnxScreen: Unable to change mode, use io-display instead.");
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
bool QQnxScreen::supportsDepth(int depth) const
|
||||
{
|
||||
// only 32-bit for the moment
|
||||
return depth == 32;
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
void QQnxScreen::exposeRegion(QRegion r, int changing)
|
||||
{
|
||||
// here is where the actual magic happens. QWS will call exposeRegion whenever
|
||||
// a region on the screen is dirty and needs to be updated on the actual screen.
|
||||
|
||||
// first, call the parent implementation. The parent implementation will update
|
||||
// the region on our in-memory surface
|
||||
QScreen::exposeRegion(r, changing);
|
||||
|
||||
// now our in-memory surface should be up to date with the latest changes.
|
||||
// the code below copies the region from the in-memory surface to the hardware.
|
||||
|
||||
// just get the bounding rectangle of the region. Most screen updates are rectangular
|
||||
// anyways. Code could be optimized to blit each and every member of the region
|
||||
// individually, but in real life, the speed-up is neglectable
|
||||
const QRect br = r.boundingRect();
|
||||
if (br.isEmpty())
|
||||
return; // ignore empty regions because gf_draw_blit2 doesn't like 0x0 dimensions
|
||||
|
||||
// start drawing.
|
||||
int ret = gf_draw_begin(d->context);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_draw_begin() failed with error code %d", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// blit the changed region from the memory surface to the hardware surface
|
||||
ret = gf_draw_blit2(d->context, d->memSurface, d->hwSurface,
|
||||
br.x(), br.y(), br.right(), br.bottom(), br.x(), br.y());
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d", ret);
|
||||
}
|
||||
|
||||
// flush all drawing commands (in our case, a single blit)
|
||||
ret = gf_draw_flush(d->context);
|
||||
if (ret != GF_ERR_OK) {
|
||||
qWarning("QQnxScreen: gf_draw_flush() failed with error code %d", ret);
|
||||
}
|
||||
|
||||
// tell QNX that we're done drawing.
|
||||
gf_draw_end(d->context);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,82 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENQNX_QWS_H
|
||||
#define QSCREENQNX_QWS_H
|
||||
|
||||
#include <QtGui/qscreen_qws.h>
|
||||
|
||||
#ifndef QT_NO_QWS_QNX
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
struct QQnxScreenContext;
|
||||
|
||||
class QQnxScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
explicit QQnxScreen(int display_id);
|
||||
~QQnxScreen();
|
||||
|
||||
bool initDevice();
|
||||
bool connect(const QString &displaySpec);
|
||||
void disconnect();
|
||||
void shutdownDevice();
|
||||
void setMode(int,int,int);
|
||||
bool supportsDepth(int) const;
|
||||
|
||||
void exposeRegion(QRegion r, int changing);
|
||||
|
||||
private:
|
||||
QQnxScreenContext * const d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QT_NO_QWS_QNX
|
||||
|
||||
#endif
|
@ -1,748 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qscreentransformed_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_TRANSFORMED
|
||||
#include <qscreendriverfactory_qws.h>
|
||||
#include <qvector.h>
|
||||
#include <private/qpainter_p.h>
|
||||
#include <private/qmemrotate_p.h>
|
||||
#include <qmatrix.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qwsdisplay_qws.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
//#define QT_REGION_DEBUG
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
#include <QDebug>
|
||||
#endif
|
||||
|
||||
class QTransformedScreenPrivate
|
||||
{
|
||||
public:
|
||||
QTransformedScreenPrivate(QTransformedScreen *parent);
|
||||
|
||||
void configure();
|
||||
|
||||
QTransformedScreen::Transformation transformation;
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
bool doGenericColors;
|
||||
#endif
|
||||
QTransformedScreen *q;
|
||||
};
|
||||
|
||||
QTransformedScreenPrivate::QTransformedScreenPrivate(QTransformedScreen *parent)
|
||||
: transformation(QTransformedScreen::None),
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
doGenericColors(false),
|
||||
#endif
|
||||
q(parent)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C"
|
||||
#ifndef QT_BUILD_GUI_LIB
|
||||
Q_DECL_EXPORT
|
||||
#endif
|
||||
void qws_setScreenTransformation(QScreen *that, int t)
|
||||
{
|
||||
QTransformedScreen *tscreen = static_cast<QTransformedScreen*>(that);
|
||||
tscreen->setTransformation((QTransformedScreen::Transformation)t);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Transformed Screen
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
\class QTransformedScreen
|
||||
\ingroup qws
|
||||
|
||||
\brief The QTransformedScreen class implements a screen driver for
|
||||
a transformed screen.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
Custom screen drivers can be added by subclassing the
|
||||
QScreenDriverPlugin class, using the QScreenDriverFactory class to
|
||||
dynamically load the driver into the application, but there should
|
||||
only be one screen object per application.
|
||||
|
||||
Use the QScreen::isTransformed() function to determine if a screen
|
||||
is transformed. The QTransformedScreen class itself provides means
|
||||
of rotating the screen with its setTransformation() function; the
|
||||
transformation() function returns the currently set rotation in
|
||||
terms of the \l Transformation enum (which describes the various
|
||||
available rotation settings). Alternatively, QTransformedScreen
|
||||
provides an implementation of the QScreen::transformOrientation()
|
||||
function, returning the current rotation as an integer value.
|
||||
|
||||
\sa QScreen, QScreenDriverPlugin, {Running Applications}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QTransformedScreen::Transformation
|
||||
|
||||
This enum describes the various rotations a transformed screen can
|
||||
have.
|
||||
|
||||
\value None No rotation
|
||||
\value Rot90 90 degrees rotation
|
||||
\value Rot180 180 degrees rotation
|
||||
\value Rot270 270 degrees rotation
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QTransformedScreen::isTransformed() const
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QTransformedScreen object. The \a displayId argument
|
||||
identifies the Qt for Embedded Linux server to connect to.
|
||||
*/
|
||||
QTransformedScreen::QTransformedScreen(int displayId)
|
||||
: QProxyScreen(displayId, QScreen::TransformedClass)
|
||||
{
|
||||
d_ptr = new QTransformedScreenPrivate(this);
|
||||
d_ptr->transformation = None;
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "QTransformedScreen::QTransformedScreen";
|
||||
#endif
|
||||
}
|
||||
|
||||
void QTransformedScreenPrivate::configure()
|
||||
{
|
||||
// ###: works because setTransformation recalculates unconditionally
|
||||
q->setTransformation(transformation);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QTransformedScreen object.
|
||||
*/
|
||||
QTransformedScreen::~QTransformedScreen()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
static int getDisplayId(const QString &spec)
|
||||
{
|
||||
QRegExp regexp(QLatin1String(":(\\d+)\\b"));
|
||||
if (regexp.lastIndexIn(spec) != -1) {
|
||||
const QString capture = regexp.cap(1);
|
||||
return capture.toInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static QTransformedScreen::Transformation filterTransformation(QString &spec)
|
||||
{
|
||||
QRegExp regexp(QLatin1String("\\bRot(\\d+):?\\b"), Qt::CaseInsensitive);
|
||||
if (regexp.indexIn(spec) == -1)
|
||||
return QTransformedScreen::None;
|
||||
|
||||
const int degrees = regexp.cap(1).toInt();
|
||||
spec.remove(regexp.pos(0), regexp.matchedLength());
|
||||
|
||||
return static_cast<QTransformedScreen::Transformation>(degrees / 90);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QTransformedScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
QString dspec = displaySpec.trimmed();
|
||||
if (dspec.startsWith(QLatin1String("Transformed:"), Qt::CaseInsensitive))
|
||||
dspec = dspec.mid(QString::fromLatin1("Transformed:").size());
|
||||
else if (!dspec.compare(QLatin1String("Transformed"), Qt::CaseInsensitive))
|
||||
dspec = QString();
|
||||
|
||||
const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
|
||||
if (dspec.endsWith(displayIdSpec))
|
||||
dspec = dspec.left(dspec.size() - displayIdSpec.size());
|
||||
|
||||
d_ptr->transformation = filterTransformation(dspec);
|
||||
|
||||
QString driver = dspec;
|
||||
int colon = driver.indexOf(QLatin1Char(':'));
|
||||
if (colon >= 0)
|
||||
driver.truncate(colon);
|
||||
|
||||
if (!QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive))
|
||||
if (!dspec.isEmpty())
|
||||
dspec.prepend(QLatin1Char(':'));
|
||||
|
||||
const int id = getDisplayId(dspec);
|
||||
QScreen *s = qt_get_screen(id, dspec.toLatin1().constData());
|
||||
setScreen(s);
|
||||
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
d_ptr->doGenericColors = dspec.contains(QLatin1String("genericcolors"));
|
||||
#endif
|
||||
|
||||
d_ptr->configure();
|
||||
|
||||
// XXX
|
||||
qt_screen = this;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the currently set rotation.
|
||||
|
||||
\sa setTransformation(), QScreen::transformOrientation()
|
||||
*/
|
||||
QTransformedScreen::Transformation QTransformedScreen::transformation() const
|
||||
{
|
||||
return d_ptr->transformation;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
int QTransformedScreen::transformOrientation() const
|
||||
{
|
||||
return (int)d_ptr->transformation;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QTransformedScreen::exposeRegion(QRegion region, int changing)
|
||||
{
|
||||
if (!data || d_ptr->transformation == None) {
|
||||
QProxyScreen::exposeRegion(region, changing);
|
||||
return;
|
||||
}
|
||||
QScreen::exposeRegion(region, changing);
|
||||
}
|
||||
|
||||
/*!
|
||||
Rotates this screen object according to the specified \a transformation.
|
||||
|
||||
\sa transformation()
|
||||
*/
|
||||
void QTransformedScreen::setTransformation(Transformation transformation)
|
||||
{
|
||||
d_ptr->transformation = transformation;
|
||||
QSize size = mapFromDevice(QSize(dw, dh));
|
||||
w = size.width();
|
||||
h = size.height();
|
||||
|
||||
const QScreen *s = screen();
|
||||
size = mapFromDevice(QSize(s->physicalWidth(), s->physicalHeight()));
|
||||
physWidth = size.width();
|
||||
physHeight = size.height();
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "QTransformedScreen::setTransformation" << transformation
|
||||
<< "size" << w << h << "dev size" << dw << dh;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static inline QRect correctNormalized(const QRect &r) {
|
||||
const int x1 = qMin(r.left(), r.right());
|
||||
const int x2 = qMax(r.left(), r.right());
|
||||
const int y1 = qMin(r.top(), r.bottom());
|
||||
const int y2 = qMax(r.top(), r.bottom());
|
||||
|
||||
return QRect( QPoint(x1,y1), QPoint(x2,y2) );
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
static inline void blit90(QScreen *screen, const QImage &image,
|
||||
const QRect &rect, const QPoint &topLeft)
|
||||
{
|
||||
const SRC *src = (const SRC*)(image.scanLine(rect.top())) + rect.left();
|
||||
DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
|
||||
+ topLeft.x();
|
||||
qt_memrotate90(src, rect.width(), rect.height(), image.bytesPerLine(),
|
||||
dest, screen->linestep());
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
static inline void blit180(QScreen *screen, const QImage &image,
|
||||
const QRect &rect, const QPoint &topLeft)
|
||||
{
|
||||
const SRC *src = (const SRC*)(image.scanLine(rect.top())) + rect.left();
|
||||
DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
|
||||
+ topLeft.x();
|
||||
qt_memrotate180(src, rect.width(), rect.height(), image.bytesPerLine(),
|
||||
dest, screen->linestep());
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
static inline void blit270(QScreen *screen, const QImage &image,
|
||||
const QRect &rect, const QPoint &topLeft)
|
||||
{
|
||||
const SRC *src = (const SRC *)(image.scanLine(rect.top())) + rect.left();
|
||||
DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
|
||||
+ topLeft.x();
|
||||
qt_memrotate270(src, rect.width(), rect.height(), image.bytesPerLine(),
|
||||
dest, screen->linestep());
|
||||
}
|
||||
|
||||
typedef void (*BlitFunc)(QScreen *, const QImage &, const QRect &, const QPoint &);
|
||||
|
||||
#define SET_BLIT_FUNC(dst, src, rotation, func) \
|
||||
do { \
|
||||
switch (rotation) { \
|
||||
case Rot90: \
|
||||
func = blit90<dst, src>; \
|
||||
break; \
|
||||
case Rot180: \
|
||||
func = blit180<dst, src>; \
|
||||
break; \
|
||||
case Rot270: \
|
||||
func = blit270<dst, src>; \
|
||||
break; \
|
||||
default: \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QTransformedScreen::blit(const QImage &image, const QPoint &topLeft,
|
||||
const QRegion ®ion)
|
||||
{
|
||||
const Transformation trans = d_ptr->transformation;
|
||||
if (trans == None) {
|
||||
QProxyScreen::blit(image, topLeft, region);
|
||||
return;
|
||||
}
|
||||
|
||||
const QVector<QRect> rects = region.rects();
|
||||
const QRect bound = QRect(0, 0, QScreen::w, QScreen::h)
|
||||
& QRect(topLeft, image.size());
|
||||
|
||||
BlitFunc func = 0;
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
if (d_ptr->doGenericColors && depth() == 16) {
|
||||
if (image.depth() == 16)
|
||||
SET_BLIT_FUNC(qrgb_generic16, quint16, trans, func);
|
||||
else
|
||||
SET_BLIT_FUNC(qrgb_generic16, quint32, trans, func);
|
||||
} else
|
||||
#endif
|
||||
switch (depth()) {
|
||||
#ifdef QT_QWS_DEPTH_32
|
||||
case 32:
|
||||
#ifdef QT_QWS_DEPTH_16
|
||||
if (image.depth() == 16)
|
||||
SET_BLIT_FUNC(quint32, quint16, trans, func);
|
||||
else
|
||||
#endif
|
||||
SET_BLIT_FUNC(quint32, quint32, trans, func);
|
||||
break;
|
||||
#endif
|
||||
#if defined(QT_QWS_DEPTH_24) || defined(QT_QWS_DEPTH18)
|
||||
case 24:
|
||||
case 18:
|
||||
SET_BLIT_FUNC(quint24, quint24, trans, func);
|
||||
break;
|
||||
#endif
|
||||
#if defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15) || defined(QT_QWS_DEPTH_12)
|
||||
case 16:
|
||||
#if defined QT_QWS_ROTATE_BGR
|
||||
if (pixelType() == BGRPixel && image.depth() == 16) {
|
||||
SET_BLIT_FUNC(qbgr565, quint16, trans, func);
|
||||
break;
|
||||
} //fall-through here!!!
|
||||
#endif
|
||||
case 15:
|
||||
#if defined QT_QWS_ROTATE_BGR
|
||||
if (pixelType() == BGRPixel && image.format() == QImage::Format_RGB555) {
|
||||
SET_BLIT_FUNC(qbgr555, qrgb555, trans, func);
|
||||
break;
|
||||
} //fall-through here!!!
|
||||
#endif
|
||||
case 12:
|
||||
if (image.depth() == 16)
|
||||
SET_BLIT_FUNC(quint16, quint16, trans, func);
|
||||
else
|
||||
SET_BLIT_FUNC(quint16, quint32, trans, func);
|
||||
break;
|
||||
#endif
|
||||
#ifdef QT_QWS_DEPTH_8
|
||||
case 8:
|
||||
if (image.format() == QImage::Format_RGB444)
|
||||
SET_BLIT_FUNC(quint8, qrgb444, trans, func);
|
||||
else if (image.depth() == 16)
|
||||
SET_BLIT_FUNC(quint8, quint16, trans, func);
|
||||
else
|
||||
SET_BLIT_FUNC(quint8, quint32, trans, func);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (!func)
|
||||
return;
|
||||
|
||||
QWSDisplay::grab();
|
||||
for (int i = 0; i < rects.size(); ++i) {
|
||||
const QRect r = rects.at(i) & bound;
|
||||
|
||||
QPoint dst;
|
||||
switch (trans) {
|
||||
case Rot90:
|
||||
dst = mapToDevice(r.topRight(), QSize(w, h));
|
||||
break;
|
||||
case Rot180:
|
||||
dst = mapToDevice(r.bottomRight(), QSize(w, h));
|
||||
break;
|
||||
case Rot270:
|
||||
dst = mapToDevice(r.bottomLeft(), QSize(w, h));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
func(this, image, r.translated(-topLeft), dst);
|
||||
}
|
||||
QWSDisplay::ungrab();
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QTransformedScreen::solidFill(const QColor &color, const QRegion ®ion)
|
||||
{
|
||||
const QRegion tr = mapToDevice(region, QSize(w,h));
|
||||
|
||||
Q_ASSERT(tr.boundingRect() == mapToDevice(region.boundingRect(), QSize(w,h)));
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "QTransformedScreen::solidFill region" << region << "transformed" << tr;
|
||||
#endif
|
||||
QProxyScreen::solidFill(color, tr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QSize QTransformedScreen::mapToDevice(const QSize &s) const
|
||||
{
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
case Rot180:
|
||||
break;
|
||||
case Rot90:
|
||||
case Rot270:
|
||||
return QSize(s.height(), s.width());
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QSize QTransformedScreen::mapFromDevice(const QSize &s) const
|
||||
{
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
case Rot180:
|
||||
break;
|
||||
case Rot90:
|
||||
case Rot270:
|
||||
return QSize(s.height(), s.width());
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QPoint QTransformedScreen::mapToDevice(const QPoint &p, const QSize &s) const
|
||||
{
|
||||
QPoint rp(p);
|
||||
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
break;
|
||||
case Rot90:
|
||||
rp.setX(p.y());
|
||||
rp.setY(s.width() - p.x() - 1);
|
||||
break;
|
||||
case Rot180:
|
||||
rp.setX(s.width() - p.x() - 1);
|
||||
rp.setY(s.height() - p.y() - 1);
|
||||
break;
|
||||
case Rot270:
|
||||
rp.setX(s.height() - p.y() - 1);
|
||||
rp.setY(p.x());
|
||||
break;
|
||||
}
|
||||
|
||||
return rp;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QPoint QTransformedScreen::mapFromDevice(const QPoint &p, const QSize &s) const
|
||||
{
|
||||
QPoint rp(p);
|
||||
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
break;
|
||||
case Rot90:
|
||||
rp.setX(s.height() - p.y() - 1);
|
||||
rp.setY(p.x());
|
||||
break;
|
||||
case Rot180:
|
||||
rp.setX(s.width() - p.x() - 1);
|
||||
rp.setY(s.height() - p.y() - 1);
|
||||
break;
|
||||
case Rot270:
|
||||
rp.setX(p.y());
|
||||
rp.setY(s.width() - p.x() - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return rp;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRect QTransformedScreen::mapToDevice(const QRect &r, const QSize &s) const
|
||||
{
|
||||
if (r.isNull())
|
||||
return QRect();
|
||||
|
||||
QRect tr;
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
tr = r;
|
||||
break;
|
||||
case Rot90:
|
||||
tr.setCoords(r.y(), s.width() - r.x() - 1,
|
||||
r.bottom(), s.width() - r.right() - 1);
|
||||
break;
|
||||
case Rot180:
|
||||
tr.setCoords(s.width() - r.x() - 1, s.height() - r.y() - 1,
|
||||
s.width() - r.right() - 1, s.height() - r.bottom() - 1);
|
||||
break;
|
||||
case Rot270:
|
||||
tr.setCoords(s.height() - r.y() - 1, r.x(),
|
||||
s.height() - r.bottom() - 1, r.right());
|
||||
break;
|
||||
}
|
||||
|
||||
return correctNormalized(tr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRect QTransformedScreen::mapFromDevice(const QRect &r, const QSize &s) const
|
||||
{
|
||||
if (r.isNull())
|
||||
return QRect();
|
||||
|
||||
QRect tr;
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
tr = r;
|
||||
break;
|
||||
case Rot90:
|
||||
tr.setCoords(s.height() - r.y() - 1, r.x(),
|
||||
s.height() - r.bottom() - 1, r.right());
|
||||
break;
|
||||
case Rot180:
|
||||
tr.setCoords(s.width() - r.x() - 1, s.height() - r.y() - 1,
|
||||
s.width() - r.right() - 1, s.height() - r.bottom() - 1);
|
||||
break;
|
||||
case Rot270:
|
||||
tr.setCoords(r.y(), s.width() - r.x() - 1,
|
||||
r.bottom(), s.width() - r.right() - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
return correctNormalized(tr);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QTransformedScreen::mapToDevice(const QRegion &rgn, const QSize &s) const
|
||||
{
|
||||
if (d_ptr->transformation == None)
|
||||
return QProxyScreen::mapToDevice(rgn, s);
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "mapToDevice size" << s << "rgn: " << rgn;
|
||||
#endif
|
||||
QRect tr;
|
||||
QRegion trgn;
|
||||
QVector<QRect> a = rgn.rects();
|
||||
const QRect *r = a.data();
|
||||
|
||||
int w = s.width();
|
||||
int h = s.height();
|
||||
int size = a.size();
|
||||
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
break;
|
||||
case Rot90:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(r->y(), w - r->x() - 1,
|
||||
r->bottom(), w - r->right() - 1);
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
case Rot180:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(w - r->x() - 1, h - r->y() - 1,
|
||||
w - r->right() - 1, h - r->bottom() - 1);
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
case Rot270:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(h - r->y() - 1, r->x(),
|
||||
h - r->bottom() - 1, r->right());
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "mapToDevice trgn: " << trgn;
|
||||
#endif
|
||||
return trgn;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QTransformedScreen::mapFromDevice(const QRegion &rgn, const QSize &s) const
|
||||
{
|
||||
if (d_ptr->transformation == None)
|
||||
return QProxyScreen::mapFromDevice(rgn, s);
|
||||
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "fromDevice: realRegion count: " << rgn.rects().size() << " isEmpty? " << rgn.isEmpty() << " bounds:" << rgn.boundingRect();
|
||||
#endif
|
||||
QRect tr;
|
||||
QRegion trgn;
|
||||
QVector<QRect> a = rgn.rects();
|
||||
const QRect *r = a.data();
|
||||
|
||||
int w = s.width();
|
||||
int h = s.height();
|
||||
int size = a.size();
|
||||
|
||||
switch (d_ptr->transformation) {
|
||||
case None:
|
||||
break;
|
||||
case Rot90:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(h - r->y() - 1, r->x(),
|
||||
h - r->bottom() - 1, r->right());
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
case Rot180:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(w - r->x() - 1, h - r->y() - 1,
|
||||
w - r->right() - 1, h - r->bottom() - 1);
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
case Rot270:
|
||||
for (int i = 0; i < size; i++, r++) {
|
||||
tr.setCoords(r->y(), w - r->x() - 1,
|
||||
r->bottom(), w - r->right() - 1);
|
||||
trgn |= correctNormalized(tr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef QT_REGION_DEBUG
|
||||
qDebug() << "fromDevice: transRegion count: " << trgn.rects().size() << " isEmpty? " << trgn.isEmpty() << " bounds:" << trgn.boundingRect();
|
||||
#endif
|
||||
return trgn;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QTransformedScreen::setDirty(const QRect& rect)
|
||||
{
|
||||
const QRect r = mapToDevice(rect, QSize(width(), height()));
|
||||
QProxyScreen::setDirty(r);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRegion QTransformedScreen::region() const
|
||||
{
|
||||
QRegion deviceRegion = QProxyScreen::region();
|
||||
return mapFromDevice(deviceRegion, QSize(deviceWidth(), deviceHeight()));
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_TRANSFORMED
|
@ -1,103 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENTRANSFORMED_QWS_H
|
||||
#define QSCREENTRANSFORMED_QWS_H
|
||||
|
||||
#include <QtGui/qscreenproxy_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_TRANSFORMED
|
||||
|
||||
class QTransformedScreenPrivate;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QTransformedScreen : public QProxyScreen
|
||||
{
|
||||
public:
|
||||
explicit QTransformedScreen(int display_id);
|
||||
~QTransformedScreen();
|
||||
|
||||
enum Transformation { None, Rot90, Rot180, Rot270 };
|
||||
|
||||
void setTransformation(Transformation t);
|
||||
Transformation transformation() const;
|
||||
int transformOrientation() const;
|
||||
|
||||
QSize mapToDevice(const QSize &s) const;
|
||||
QSize mapFromDevice(const QSize &s) const;
|
||||
|
||||
QPoint mapToDevice(const QPoint &, const QSize &) const;
|
||||
QPoint mapFromDevice(const QPoint &, const QSize &) const;
|
||||
|
||||
QRect mapToDevice(const QRect &, const QSize &) const;
|
||||
QRect mapFromDevice(const QRect &, const QSize &) const;
|
||||
|
||||
QRegion mapToDevice(const QRegion &, const QSize &) const;
|
||||
QRegion mapFromDevice(const QRegion &, const QSize &) const;
|
||||
|
||||
bool connect(const QString &displaySpec);
|
||||
|
||||
bool isTransformed() const { return transformation() != None; }
|
||||
|
||||
void exposeRegion(QRegion region, int changing);
|
||||
void blit(const QImage &img, const QPoint &topLeft, const QRegion ®ion);
|
||||
void solidFill(const QColor &color, const QRegion ®ion);
|
||||
void setDirty(const QRect&);
|
||||
|
||||
QRegion region() const;
|
||||
|
||||
private:
|
||||
friend class QTransformedScreenPrivate;
|
||||
QTransformedScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_TRANSFORMED
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENTRANSFORMED_QWS_H
|
@ -1,445 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_QVFB
|
||||
|
||||
#define QTOPIA_QVFB_BRIGHTNESS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <qvfbhdr.h>
|
||||
#include <qscreenvfb_qws.h>
|
||||
#include <qkbdvfb_qws.h>
|
||||
#include <qmousevfb_qws.h>
|
||||
#include <qwindowsystem_qws.h>
|
||||
#include <qsocketnotifier.h>
|
||||
#include <qapplication.h>
|
||||
#include <qscreen_qws.h>
|
||||
#include <qmousedriverfactory_qws.h>
|
||||
#include <qkbddriverfactory_qws.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QVFbScreenPrivate
|
||||
{
|
||||
public:
|
||||
QVFbScreenPrivate();
|
||||
~QVFbScreenPrivate();
|
||||
|
||||
bool success;
|
||||
unsigned char *shmrgn;
|
||||
int brightness;
|
||||
bool blank;
|
||||
QVFbHeader *hdr;
|
||||
QWSMouseHandler *mouse;
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
QWSKeyboardHandler *keyboard;
|
||||
#endif
|
||||
};
|
||||
|
||||
QVFbScreenPrivate::QVFbScreenPrivate()
|
||||
: mouse(0)
|
||||
|
||||
{
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
keyboard = 0;
|
||||
#endif
|
||||
brightness = 255;
|
||||
blank = false;
|
||||
}
|
||||
|
||||
QVFbScreenPrivate::~QVFbScreenPrivate()
|
||||
{
|
||||
delete mouse;
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
delete keyboard;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
\class QVFbScreen
|
||||
\ingroup qws
|
||||
|
||||
\brief The QVFbScreen class implements a screen driver for the
|
||||
virtual framebuffer.
|
||||
|
||||
Note that this class is only available in \l{Qt for Embedded Linux}.
|
||||
Custom screen drivers can be added by subclassing the
|
||||
QScreenDriverPlugin class, using the QScreenDriverFactory class to
|
||||
dynamically load the driver into the application, but there should
|
||||
only be one screen object per application.
|
||||
|
||||
The Qt for Embedded Linux platform provides a \l{The Virtual
|
||||
Framebuffer}{virtual framebuffer} for development and debugging;
|
||||
the virtual framebuffer allows Qt for Embedded Linux applications to be
|
||||
developed on a desktop machine, without switching between consoles
|
||||
and X11.
|
||||
|
||||
\sa QScreen, QScreenDriverPlugin, {Running Applications}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QVFbScreen::connect(const QString & displaySpec)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::disconnect()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QVFbScreen::initDevice()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::restore()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::save()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::setDirty(const QRect & r)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::setMode(int nw, int nh, int nd)
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVFbScreen::shutdownDevice()
|
||||
\reimp
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVFbScreen::QVFbScreen(int displayId)
|
||||
|
||||
Constructs a QVNCScreen object. The \a displayId argument
|
||||
identifies the Qt for Embedded Linux server to connect to.
|
||||
*/
|
||||
QVFbScreen::QVFbScreen(int display_id)
|
||||
: QScreen(display_id, VFbClass), d_ptr(new QVFbScreenPrivate)
|
||||
{
|
||||
d_ptr->shmrgn = 0;
|
||||
d_ptr->hdr = 0;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QVFbScreen object.
|
||||
*/
|
||||
QVFbScreen::~QVFbScreen()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
static QVFbScreen *connected = 0;
|
||||
|
||||
bool QVFbScreen::connect(const QString &displaySpec)
|
||||
{
|
||||
QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
|
||||
if (displayArgs.contains(QLatin1String("Gray")))
|
||||
grayscale = true;
|
||||
|
||||
key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLocal8Bit(), 'b');
|
||||
|
||||
if (key == -1)
|
||||
return false;
|
||||
|
||||
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
||||
#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
|
||||
if (displayArgs.contains(QLatin1String("littleendian")))
|
||||
#endif
|
||||
QScreen::setFrameBufferLittleEndian(true);
|
||||
#endif
|
||||
|
||||
int shmId = shmget(key, 0, 0);
|
||||
if (shmId != -1)
|
||||
d_ptr->shmrgn = (unsigned char *)shmat(shmId, 0, 0);
|
||||
else
|
||||
return false;
|
||||
|
||||
if ((long)d_ptr->shmrgn == -1 || d_ptr->shmrgn == 0) {
|
||||
qDebug("No shmrgn %ld", (long)d_ptr->shmrgn);
|
||||
return false;
|
||||
}
|
||||
|
||||
d_ptr->hdr = (QVFbHeader *)d_ptr->shmrgn;
|
||||
data = d_ptr->shmrgn + d_ptr->hdr->dataoffset;
|
||||
|
||||
dw = w = d_ptr->hdr->width;
|
||||
dh = h = d_ptr->hdr->height;
|
||||
d = d_ptr->hdr->depth;
|
||||
|
||||
switch (d) {
|
||||
case 1:
|
||||
setPixelFormat(QImage::Format_Mono);
|
||||
break;
|
||||
case 8:
|
||||
setPixelFormat(QImage::Format_Indexed8);
|
||||
break;
|
||||
case 12:
|
||||
setPixelFormat(QImage::Format_RGB444);
|
||||
break;
|
||||
case 15:
|
||||
setPixelFormat(QImage::Format_RGB555);
|
||||
break;
|
||||
case 16:
|
||||
setPixelFormat(QImage::Format_RGB16);
|
||||
break;
|
||||
case 18:
|
||||
setPixelFormat(QImage::Format_RGB666);
|
||||
break;
|
||||
case 24:
|
||||
setPixelFormat(QImage::Format_RGB888);
|
||||
break;
|
||||
case 32:
|
||||
setPixelFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
break;
|
||||
}
|
||||
|
||||
lstep = d_ptr->hdr->linestep;
|
||||
|
||||
// Handle display physical size spec.
|
||||
int dimIdxW = -1;
|
||||
int dimIdxH = -1;
|
||||
for (int i = 0; i < displayArgs.size(); ++i) {
|
||||
if (displayArgs.at(i).startsWith(QLatin1String("mmWidth"))) {
|
||||
dimIdxW = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < displayArgs.size(); ++i) {
|
||||
if (displayArgs.at(i).startsWith(QLatin1String("mmHeight"))) {
|
||||
dimIdxH = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dimIdxW >= 0) {
|
||||
bool ok;
|
||||
int pos = 7;
|
||||
if (displayArgs.at(dimIdxW).at(pos) == QLatin1Char('='))
|
||||
++pos;
|
||||
int pw = displayArgs.at(dimIdxW).mid(pos).toInt(&ok);
|
||||
if (ok) {
|
||||
physWidth = pw;
|
||||
if (dimIdxH < 0)
|
||||
physHeight = dh*physWidth/dw;
|
||||
}
|
||||
}
|
||||
if (dimIdxH >= 0) {
|
||||
bool ok;
|
||||
int pos = 8;
|
||||
if (displayArgs.at(dimIdxH).at(pos) == QLatin1Char('='))
|
||||
++pos;
|
||||
int ph = displayArgs.at(dimIdxH).mid(pos).toInt(&ok);
|
||||
if (ok) {
|
||||
physHeight = ph;
|
||||
if (dimIdxW < 0)
|
||||
physWidth = dw*physHeight/dh;
|
||||
}
|
||||
}
|
||||
if (dimIdxW < 0 && dimIdxH < 0) {
|
||||
const int dpi = 72;
|
||||
physWidth = qRound(dw * 25.4 / dpi);
|
||||
physHeight = qRound(dh * 25.4 / dpi);
|
||||
}
|
||||
|
||||
qDebug("Connected to VFB server %s: %d x %d x %d %dx%dmm (%dx%ddpi)", displaySpec.toLatin1().data(),
|
||||
w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
|
||||
|
||||
size = lstep * h;
|
||||
mapsize = size;
|
||||
screencols = d_ptr->hdr->numcols;
|
||||
memcpy(screenclut, d_ptr->hdr->clut, sizeof(QRgb) * screencols);
|
||||
|
||||
connected = this;
|
||||
|
||||
if (qgetenv("QT_QVFB_BGR").toInt())
|
||||
pixeltype = BGRPixel;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QVFbScreen::disconnect()
|
||||
{
|
||||
connected = 0;
|
||||
if ((long)d_ptr->shmrgn != -1 && d_ptr->shmrgn) {
|
||||
if (qApp->type() == QApplication::GuiServer && d_ptr->hdr->dataoffset >= (int)sizeof(QVFbHeader)) {
|
||||
d_ptr->hdr->serverVersion = 0;
|
||||
}
|
||||
shmdt((char*)d_ptr->shmrgn);
|
||||
}
|
||||
}
|
||||
|
||||
bool QVFbScreen::initDevice()
|
||||
{
|
||||
#ifndef QT_NO_QWS_MOUSE_QVFB
|
||||
const QString mouseDev = QT_VFB_MOUSE_PIPE(displayId);
|
||||
d_ptr->mouse = new QVFbMouseHandler(QLatin1String("QVFbMouse"), mouseDev);
|
||||
qwsServer->setDefaultMouse("None");
|
||||
if (d_ptr->mouse)
|
||||
d_ptr->mouse->setScreen(this);
|
||||
#endif
|
||||
|
||||
#if !defined(QT_NO_QWS_KBD_QVFB) && !defined(QT_NO_QWS_KEYBOARD)
|
||||
const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId);
|
||||
d_ptr->keyboard = new QVFbKeyboardHandler(keyboardDev);
|
||||
qwsServer->setDefaultKeyboard("None");
|
||||
#endif
|
||||
|
||||
if (d_ptr->hdr->dataoffset >= (int)sizeof(QVFbHeader))
|
||||
d_ptr->hdr->serverVersion = QT_VERSION;
|
||||
|
||||
if(d==8) {
|
||||
screencols=256;
|
||||
if (grayscale) {
|
||||
// Build grayscale palette
|
||||
for(int loopc=0;loopc<256;loopc++) {
|
||||
screenclut[loopc]=qRgb(loopc,loopc,loopc);
|
||||
}
|
||||
} else {
|
||||
// 6x6x6 216 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) {
|
||||
screenclut[idx]=qRgb(ir, ig, ib);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
screencols=idx;
|
||||
}
|
||||
memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
|
||||
d_ptr->hdr->numcols = screencols;
|
||||
} else if (d == 4) {
|
||||
int val = 0;
|
||||
for (int idx = 0; idx < 16; idx++, val += 17) {
|
||||
screenclut[idx] = qRgb(val, val, val);
|
||||
}
|
||||
screencols = 16;
|
||||
memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
|
||||
d_ptr->hdr->numcols = screencols;
|
||||
} else if (d == 1) {
|
||||
screencols = 2;
|
||||
screenclut[1] = qRgb(0xff, 0xff, 0xff);
|
||||
screenclut[0] = qRgb(0, 0, 0);
|
||||
memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
|
||||
d_ptr->hdr->numcols = screencols;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
QScreenCursor::initSoftwareCursor();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void QVFbScreen::shutdownDevice()
|
||||
{
|
||||
}
|
||||
|
||||
void QVFbScreen::setMode(int ,int ,int)
|
||||
{
|
||||
}
|
||||
|
||||
// save the state of the graphics card
|
||||
// This is needed so that e.g. we can restore the palette when switching
|
||||
// between linux virtual consoles.
|
||||
void QVFbScreen::save()
|
||||
{
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
// restore the state of the graphics card.
|
||||
void QVFbScreen::restore()
|
||||
{
|
||||
}
|
||||
void QVFbScreen::setDirty(const QRect& rect)
|
||||
{
|
||||
const QRect r = rect.translated(-offset());
|
||||
d_ptr->hdr->dirty = true;
|
||||
d_ptr->hdr->update = d_ptr->hdr->update.united(r);
|
||||
}
|
||||
|
||||
void QVFbScreen::setBrightness(int b)
|
||||
{
|
||||
if (connected) {
|
||||
connected->d_ptr->brightness = b;
|
||||
|
||||
QVFbHeader *hdr = connected->d_ptr->hdr;
|
||||
if (hdr->viewerVersion < 0x040400) // brightness not supported
|
||||
return;
|
||||
|
||||
const int br = connected->d_ptr->blank ? 0 : b;
|
||||
if (hdr->brightness != br) {
|
||||
hdr->brightness = br;
|
||||
connected->setDirty(connected->region().boundingRect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QVFbScreen::blank(bool on)
|
||||
{
|
||||
d_ptr->blank = on;
|
||||
setBrightness(connected->d_ptr->brightness);
|
||||
}
|
||||
|
||||
#endif // QT_NO_QWS_QVFB
|
||||
|
||||
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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSCREENVFB_QWS_H
|
||||
#define QSCREENVFB_QWS_H
|
||||
|
||||
#include <QtGui/qscreen_qws.h>
|
||||
#include <QtGui/qvfbhdr.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_QVFB
|
||||
|
||||
class QVFbScreenPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QVFbScreen : public QScreen
|
||||
{
|
||||
public:
|
||||
explicit QVFbScreen(int display_id);
|
||||
virtual ~QVFbScreen();
|
||||
virtual bool initDevice();
|
||||
virtual bool connect(const QString &displaySpec);
|
||||
virtual void disconnect();
|
||||
virtual void shutdownDevice();
|
||||
virtual void save();
|
||||
virtual void restore();
|
||||
virtual void setMode(int nw,int nh,int nd);
|
||||
virtual void setDirty(const QRect& r);
|
||||
virtual void blank(bool);
|
||||
#ifdef QTOPIA_QVFB_BRIGHTNESS
|
||||
static void setBrightness(int b);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QVFbScreenPrivate *d_ptr;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_QVFB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSCREENVFB_QWS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,177 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSOUNDQSS_QWS_H
|
||||
#define QSOUNDQSS_QWS_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
|
||||
#include <QtNetwork/qtcpserver.h>
|
||||
#include <QtNetwork/qtcpsocket.h>
|
||||
#include <QtGui/qwssocket_qws.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#if defined(QT_NO_NETWORK) || defined(QT_NO_DNS)
|
||||
#define QT_NO_QWS_SOUNDSERVER
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
|
||||
class QWSSoundServerPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QWSSoundServer : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QWSSoundServer(QObject *parent=0);
|
||||
~QWSSoundServer();
|
||||
void playFile( int id, const QString& filename );
|
||||
void stopFile( int id );
|
||||
void pauseFile( int id );
|
||||
void resumeFile( int id );
|
||||
|
||||
Q_SIGNALS:
|
||||
void soundCompleted( int );
|
||||
|
||||
private Q_SLOTS:
|
||||
void translateSoundCompleted( int, int );
|
||||
|
||||
private:
|
||||
QWSSoundServerPrivate* d;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_QWS_SOUNDSERVER
|
||||
class Q_GUI_EXPORT QWSSoundClient : public QWSSocket {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum SoundFlags {
|
||||
Priority = 0x01,
|
||||
Streaming = 0x02 // currently ignored, but but could set up so both Raw and non raw can be done streaming or not.
|
||||
};
|
||||
enum DeviceErrors {
|
||||
ErrOpeningAudioDevice = 0x01,
|
||||
ErrOpeningFile = 0x02,
|
||||
ErrReadingFile = 0x04
|
||||
};
|
||||
explicit QWSSoundClient(QObject* parent=0);
|
||||
~QWSSoundClient( );
|
||||
void reconnect();
|
||||
void play( int id, const QString& filename );
|
||||
void play( int id, const QString& filename, int volume, int flags = 0 );
|
||||
void playRaw( int id, const QString&, int, int, int, int flags = 0 );
|
||||
|
||||
void pause( int id );
|
||||
void stop( int id );
|
||||
void resume( int id );
|
||||
void setVolume( int id, int left, int right );
|
||||
void setMute( int id, bool m );
|
||||
|
||||
// to be used by server only, to protect phone conversation/rings.
|
||||
void playPriorityOnly(bool);
|
||||
|
||||
// If silent, tell sound server to release audio device
|
||||
// Otherwise, allow sound server to regain audio device
|
||||
void setSilent(bool);
|
||||
|
||||
Q_SIGNALS:
|
||||
void soundCompleted(int);
|
||||
void deviceReady(int id);
|
||||
void deviceError(int id, QWSSoundClient::DeviceErrors);
|
||||
|
||||
private Q_SLOTS:
|
||||
void tryReadCommand();
|
||||
void emitConnectionRefused();
|
||||
|
||||
private:
|
||||
void sendServerMessage(QString msg);
|
||||
};
|
||||
|
||||
class QWSSoundServerSocket : public QWSServerSocket {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QWSSoundServerSocket(QObject *parent=0);
|
||||
public Q_SLOTS:
|
||||
void newConnection();
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
public:
|
||||
QT3_SUPPORT_CONSTRUCTOR QWSSoundServerSocket(QObject *parent, const char *name);
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void playFile(int, int, const QString&);
|
||||
void playFile(int, int, const QString&, int, int);
|
||||
void playRawFile(int, int, const QString&, int, int, int, int);
|
||||
void pauseFile(int, int);
|
||||
void stopFile(int, int);
|
||||
void resumeFile(int, int);
|
||||
void setVolume(int, int, int, int);
|
||||
void setMute(int, int, bool);
|
||||
|
||||
void stopAll(int);
|
||||
|
||||
void playPriorityOnly(bool);
|
||||
|
||||
void setSilent(bool);
|
||||
|
||||
void soundFileCompleted(int, int);
|
||||
void deviceReady(int, int);
|
||||
void deviceError(int, int, int);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QT_NO_SOUND
|
||||
|
||||
#endif // QSOUNDQSS_QWS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,281 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTRANSPORTAUTH_QWS_H
|
||||
#define QTRANSPORTAUTH_QWS_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if !defined(QT_NO_SXE) || defined(SXE_INSTALLER)
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qbuffer.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QAuthDevice;
|
||||
class QWSClient;
|
||||
class QIODevice;
|
||||
class QTransportAuthPrivate;
|
||||
class QMutex;
|
||||
|
||||
class Q_GUI_EXPORT QTransportAuth : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QTransportAuth *getInstance();
|
||||
|
||||
enum Result {
|
||||
// Error codes
|
||||
Pending = 0x00,
|
||||
TooSmall = 0x01,
|
||||
CacheMiss = 0x02,
|
||||
NoMagic = 0x03,
|
||||
NoSuchKey = 0x04,
|
||||
FailMatch = 0x05,
|
||||
OutOfDate = 0x06,
|
||||
// reserved for expansion
|
||||
Success = 0x1e,
|
||||
ErrMask = 0x1f,
|
||||
|
||||
// Verification codes
|
||||
Allow = 0x20,
|
||||
Deny = 0x40,
|
||||
Ask = 0x60,
|
||||
// reserved
|
||||
StatusMask = 0xe0
|
||||
};
|
||||
|
||||
enum Properties {
|
||||
Trusted = 0x01,
|
||||
Connection = 0x02,
|
||||
UnixStreamSock = 0x04,
|
||||
SharedMemory = 0x08,
|
||||
MessageQueue = 0x10,
|
||||
UDP = 0x20,
|
||||
TCP = 0x40,
|
||||
UserDefined = 0x80,
|
||||
TransportType = 0xfc
|
||||
};
|
||||
|
||||
struct Data
|
||||
{
|
||||
Data() { processId = -1; }
|
||||
Data( unsigned char p, int d )
|
||||
: properties( p )
|
||||
, descriptor( d )
|
||||
, processId( -1 )
|
||||
{
|
||||
if (( properties & TransportType ) == TCP ||
|
||||
( properties & TransportType ) == UnixStreamSock )
|
||||
properties |= Connection;
|
||||
}
|
||||
|
||||
unsigned char properties;
|
||||
unsigned char progId;
|
||||
unsigned char status;
|
||||
unsigned int descriptor; // socket fd or shmget key
|
||||
pid_t processId;
|
||||
|
||||
bool trusted() const;
|
||||
void setTrusted( bool );
|
||||
bool connection() const;
|
||||
void setConnection( bool );
|
||||
};
|
||||
|
||||
static const char *errorString( const QTransportAuth::Data & );
|
||||
|
||||
QTransportAuth::Data *connectTransport( unsigned char, int );
|
||||
|
||||
QAuthDevice *authBuf( QTransportAuth::Data *, QIODevice * );
|
||||
QAuthDevice *recvBuf( QTransportAuth::Data *, QIODevice * );
|
||||
QIODevice *passThroughByClient( QWSClient * ) const;
|
||||
|
||||
void setKeyFilePath( const QString & );
|
||||
QString keyFilePath() const;
|
||||
const unsigned char *getClientKey( unsigned char progId );
|
||||
void invalidateClientKeyCache();
|
||||
QMutex *getKeyFileMutex();
|
||||
void setLogFilePath( const QString & );
|
||||
QString logFilePath() const;
|
||||
void setPackageRegistry( QObject *registry );
|
||||
bool isDiscoveryMode() const;
|
||||
void setProcessKey( const char * );
|
||||
void setProcessKey( const char *, const char * );
|
||||
void registerPolicyReceiver( QObject * );
|
||||
void unregisterPolicyReceiver( QObject * );
|
||||
|
||||
bool authToMessage( QTransportAuth::Data &d, char *hdr, const char *msg, int msgLen );
|
||||
bool authFromMessage( QTransportAuth::Data &d, const char *msg, int msgLen );
|
||||
|
||||
bool authorizeRequest( QTransportAuth::Data &d, const QString &request );
|
||||
|
||||
Q_SIGNALS:
|
||||
void policyCheck( QTransportAuth::Data &, const QString & );
|
||||
void authViolation( QTransportAuth::Data & );
|
||||
private Q_SLOTS:
|
||||
void bufferDestroyed( QObject * );
|
||||
|
||||
private:
|
||||
// users should never construct their own
|
||||
QTransportAuth();
|
||||
~QTransportAuth();
|
||||
|
||||
friend class QAuthDevice;
|
||||
Q_DECLARE_PRIVATE(QTransportAuth)
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT RequestAnalyzer
|
||||
{
|
||||
public:
|
||||
RequestAnalyzer();
|
||||
virtual ~RequestAnalyzer();
|
||||
QString operator()( QByteArray *data ) { return analyze( data ); }
|
||||
bool requireMoreData() const { return moreData; }
|
||||
qint64 bytesAnalyzed() const { return dataSize; }
|
||||
protected:
|
||||
virtual QString analyze( QByteArray * );
|
||||
bool moreData;
|
||||
qint64 dataSize;
|
||||
};
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QAuthDevice
|
||||
|
||||
\brief Pass-through QIODevice sub-class for authentication.
|
||||
|
||||
Use this class to forward on or receive forwarded data over a real
|
||||
device for authentication.
|
||||
*/
|
||||
class Q_GUI_EXPORT QAuthDevice : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum AuthDirection {
|
||||
Receive,
|
||||
Send
|
||||
};
|
||||
QAuthDevice( QIODevice *, QTransportAuth::Data *, AuthDirection );
|
||||
~QAuthDevice();
|
||||
void setTarget( QIODevice *t ) { m_target = t; }
|
||||
QIODevice *target() const { return m_target; }
|
||||
void setClient( QObject* );
|
||||
QObject *client() const;
|
||||
void setRequestAnalyzer( RequestAnalyzer * );
|
||||
bool isSequential() const;
|
||||
bool atEnd() const;
|
||||
qint64 bytesAvailable() const;
|
||||
qint64 bytesToWrite() const;
|
||||
bool seek( qint64 );
|
||||
QByteArray & buffer();
|
||||
|
||||
protected:
|
||||
qint64 readData( char *, qint64 );
|
||||
qint64 writeData(const char *, qint64 );
|
||||
private Q_SLOTS:
|
||||
void recvReadyRead();
|
||||
void targetBytesWritten( qint64 );
|
||||
private:
|
||||
bool authorizeMessage();
|
||||
|
||||
QTransportAuth::Data *d;
|
||||
AuthDirection way;
|
||||
QIODevice *m_target;
|
||||
QObject *m_client;
|
||||
QByteArray msgQueue;
|
||||
qint64 m_bytesAvailable;
|
||||
qint64 m_skipWritten;
|
||||
|
||||
RequestAnalyzer *analyzer;
|
||||
};
|
||||
|
||||
inline bool QAuthDevice::isSequential() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool QAuthDevice::seek( qint64 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool QAuthDevice::atEnd() const
|
||||
{
|
||||
return msgQueue.isEmpty();
|
||||
}
|
||||
|
||||
inline qint64 QAuthDevice::bytesAvailable() const
|
||||
{
|
||||
if ( way == Receive )
|
||||
return m_bytesAvailable;
|
||||
else
|
||||
return ( m_target ? m_target->bytesAvailable() : 0 );
|
||||
}
|
||||
|
||||
inline qint64 QAuthDevice::bytesToWrite() const
|
||||
{
|
||||
return msgQueue.size();
|
||||
}
|
||||
|
||||
inline QByteArray &QAuthDevice::buffer()
|
||||
{
|
||||
return msgQueue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QT_NO_SXE
|
||||
#endif // QTRANSPORTAUTH_QWS_H
|
@ -1,189 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTRANSPORTAUTH_QWS_P_H
|
||||
#define QTRANSPORTAUTH_QWS_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/qglobal.h>
|
||||
|
||||
#ifndef QT_NO_SXE
|
||||
|
||||
#include "qtransportauth_qws.h"
|
||||
#include "qtransportauthdefs_qws.h"
|
||||
#include "qbuffer.h"
|
||||
|
||||
#include <qmutex.h>
|
||||
#include <qdatetime.h>
|
||||
#include "private/qobject_p.h"
|
||||
|
||||
#include <QtCore/qcache.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Uncomment to generate debug output
|
||||
// #define QTRANSPORTAUTH_DEBUG 1
|
||||
|
||||
#ifdef QTRANSPORTAUTH_DEBUG
|
||||
void hexstring( char *buf, const unsigned char* key, size_t sz );
|
||||
#endif
|
||||
|
||||
// proj id for ftok usage in sxe
|
||||
#define SXE_PROJ 10022
|
||||
|
||||
/*!
|
||||
\internal
|
||||
memset for security purposes, guaranteed not to be optimized away
|
||||
http://www.faqs.org/docs/Linux-HOWTO/Secure-Programs-HOWTO.html
|
||||
*/
|
||||
void *guaranteed_memset(void *v,int c,size_t n);
|
||||
|
||||
class QUnixSocketMessage;
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class AuthCookie
|
||||
Struct to carry process authentication key and id
|
||||
*/
|
||||
#define QSXE_HEADER_LEN 24
|
||||
|
||||
/*!
|
||||
\macro AUTH_ID
|
||||
Macro to manage authentication header. Format of header is:
|
||||
\table
|
||||
\header \i BYTES \i CONTENT
|
||||
\row \i 0-3 \i magic numbers
|
||||
\row \i 4 \i length of authenticated data (max 255 bytes)
|
||||
\row i\ 5 \i reserved
|
||||
\row \i 6-21 \i MAC digest, or shared secret in case of simple auth
|
||||
\row \i 22 \i program id
|
||||
\row \i 23 \i sequence number
|
||||
\endtable
|
||||
Total length of the header is 24 bytes
|
||||
|
||||
However this may change. Instead of coding these numbers use the AUTH_ID,
|
||||
AUTH_KEY, AUTH_DATA and AUTH_SPACE macros.
|
||||
*/
|
||||
|
||||
#define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
|
||||
#define AUTH_KEY(k) ((unsigned char *)(k))
|
||||
|
||||
#define AUTH_DATA(x) (unsigned char *)((x) + QSXE_HEADER_LEN)
|
||||
#define AUTH_SPACE(x) ((x) + QSXE_HEADER_LEN)
|
||||
#define QSXE_LEN_IDX 4
|
||||
#define QSXE_KEY_IDX 6
|
||||
#define QSXE_PROG_IDX 22
|
||||
#define QSXE_SEQ_IDX 23
|
||||
|
||||
class SxeRegistryLocker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SxeRegistryLocker( QObject * );
|
||||
~SxeRegistryLocker();
|
||||
bool success() const { return m_success; }
|
||||
private:
|
||||
bool m_success;
|
||||
QObject *m_reg;
|
||||
};
|
||||
|
||||
class QTransportAuthPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QTransportAuth)
|
||||
public:
|
||||
QTransportAuthPrivate();
|
||||
~QTransportAuthPrivate();
|
||||
|
||||
const unsigned char *getClientKey( unsigned char progId );
|
||||
void invalidateClientKeyCache();
|
||||
|
||||
bool keyInitialised;
|
||||
QString m_logFilePath;
|
||||
QString m_keyFilePath;
|
||||
QObject *m_packageRegistry;
|
||||
AuthCookie authKey;
|
||||
QCache<unsigned char, char> keyCache;
|
||||
QHash< QObject*, QIODevice*> buffersByClient;
|
||||
QMutex keyfileMutex;
|
||||
};
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Enforces the False Authentication Rate. If more than 4 authentications
|
||||
are received per minute the sxemonitor is notified that the FAR has been exceeded
|
||||
*/
|
||||
class FAREnforcer
|
||||
{
|
||||
public:
|
||||
static FAREnforcer *getInstance();
|
||||
void logAuthAttempt( QDateTime time = QDateTime::currentDateTime() );
|
||||
void reset();
|
||||
|
||||
#ifndef TEST_FAR_ENFORCER
|
||||
private:
|
||||
#endif
|
||||
FAREnforcer();
|
||||
FAREnforcer( const FAREnforcer & );
|
||||
FAREnforcer &operator=(FAREnforcer const & );
|
||||
|
||||
static const QString FARMessage;
|
||||
static const int minutelyRate;
|
||||
static const QString SxeTag;
|
||||
static const int minute;
|
||||
|
||||
QList<QDateTime> authAttempts;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_SXE
|
||||
#endif // QTRANSPORTAUTH_QWS_P_H
|
||||
|
@ -1,174 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTRANSPORTAUTHDEFS_QWS_H
|
||||
#define QTRANSPORTAUTHDEFS_QWS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#define QSXE_KEY_LEN 16
|
||||
#define QSXE_MAGIC_BYTES 4
|
||||
|
||||
// Number of bytes of each message to authenticate. Just need to ensure
|
||||
// that the command at the beginning hasn't been tampered with. This value
|
||||
// does not matter for trusted transports.
|
||||
#define AMOUNT_TO_AUTHENTICATE 200
|
||||
|
||||
#define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
|
||||
#define AUTH_KEY(k) ((unsigned char *)(k))
|
||||
|
||||
// must be a largish -ve number under any endianess when cast as an int
|
||||
const unsigned char magic[QSXE_MAGIC_BYTES] = { 0xBA, 0xD4, 0xD4, 0xBA };
|
||||
const int magicInt = 0xBAD4D4BA;
|
||||
|
||||
#define QSXE_KEYFILE "keyfile"
|
||||
|
||||
/*
|
||||
Header in above format, less the magic bytes.
|
||||
Useful for reading off the socket
|
||||
*/
|
||||
struct AuthHeader
|
||||
{
|
||||
unsigned char len;
|
||||
unsigned char pad;
|
||||
unsigned char digest[QSXE_KEY_LEN];
|
||||
unsigned char id;
|
||||
unsigned char seq;
|
||||
};
|
||||
|
||||
/*
|
||||
Header in a form suitable for authentication routines
|
||||
*/
|
||||
struct AuthMessage
|
||||
{
|
||||
AuthMessage()
|
||||
{
|
||||
::memset( authData, 0, sizeof(authData) );
|
||||
::memcpy( pad_magic, magic, QSXE_MAGIC_BYTES );
|
||||
}
|
||||
unsigned char pad_magic[QSXE_MAGIC_BYTES];
|
||||
union {
|
||||
AuthHeader hdr;
|
||||
char authData[sizeof(AuthHeader)];
|
||||
};
|
||||
char payLoad[AMOUNT_TO_AUTHENTICATE];
|
||||
};
|
||||
|
||||
/**
|
||||
Auth data as stored in _key
|
||||
*/
|
||||
struct AuthCookie
|
||||
{
|
||||
unsigned char key[QSXE_KEY_LEN];
|
||||
unsigned char pad;
|
||||
unsigned char progId;
|
||||
};
|
||||
|
||||
/*
|
||||
Auth data as written to the key file - SUPERSEDED by usr_key_entry
|
||||
|
||||
This is still used internally for some functions, ie the socket
|
||||
related calls.
|
||||
*/
|
||||
struct AuthRecord
|
||||
{
|
||||
union {
|
||||
AuthCookie auth;
|
||||
char data[sizeof(struct AuthCookie)];
|
||||
};
|
||||
time_t change_time;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class usr_key_entry
|
||||
This comes from the SXE kernel patch file include/linux/lidsif.h
|
||||
|
||||
This is the (new) data record for the key file (version 2).
|
||||
|
||||
The key file is (now) either /proc/lids/keys (and the per-process
|
||||
keys in /proc/<pid>/lids_key) OR for desktop/development ONLY (not
|
||||
for production) it is $QPEDIR/etc/keyfile
|
||||
|
||||
The key file maps keys to files.
|
||||
|
||||
File are identified by inode and device numbers, not paths.
|
||||
|
||||
(See the "installs" file for path to inode/device mapping)
|
||||
*/
|
||||
struct usr_key_entry
|
||||
{
|
||||
char key[QSXE_KEY_LEN];
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\class IdBlock
|
||||
\brief Data record for the manifest file.
|
||||
The manifest file maps program id's to files
|
||||
*/
|
||||
struct IdBlock
|
||||
{
|
||||
quint64 inode;
|
||||
quint64 device;
|
||||
unsigned char pad;
|
||||
unsigned char progId;
|
||||
unsigned short installId;
|
||||
unsigned int keyOffset;
|
||||
qint64 install_time;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QTRANSPORTAUTHDEFS_QWS_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,508 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWINDOWSYSTEM_QWS_H
|
||||
#define QWINDOWSYSTEM_QWS_H
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#include <QtGui/qwsevent_qws.h>
|
||||
#include <QtGui/qkbd_qws.h>
|
||||
#include <QtGui/qregion.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
struct QWSWindowPrivate;
|
||||
class QWSCursor;
|
||||
class QWSClient;
|
||||
class QWSRegionManager;
|
||||
class QBrush;
|
||||
class QVariant;
|
||||
class QInputMethodEvent;
|
||||
class QWSInputMethod;
|
||||
class QWSBackingStore;
|
||||
class QWSWindowSurface;
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
class QImage;
|
||||
class QColor;
|
||||
#endif
|
||||
|
||||
class QWSInternalWindowInfo
|
||||
{
|
||||
public:
|
||||
int winid;
|
||||
unsigned int clientid;
|
||||
QString name; // Corresponds to QObject name of top-level widget
|
||||
};
|
||||
|
||||
|
||||
class Q_GUI_EXPORT QWSScreenSaver
|
||||
{
|
||||
public:
|
||||
virtual ~QWSScreenSaver();
|
||||
virtual void restore()=0;
|
||||
virtual bool save(int level)=0;
|
||||
};
|
||||
|
||||
|
||||
class Q_GUI_EXPORT QWSWindow
|
||||
{
|
||||
friend class QWSServer;
|
||||
friend class QWSServerPrivate;
|
||||
|
||||
public:
|
||||
QWSWindow(int i, QWSClient* client);
|
||||
~QWSWindow();
|
||||
|
||||
int winId() const { return id; }
|
||||
const QString &name() const { return rgnName; }
|
||||
const QString &caption() const { return rgnCaption; }
|
||||
QWSClient* client() const { return c; }
|
||||
const QRegion &requestedRegion() const { return requested_region; }
|
||||
QRegion allocatedRegion() const;
|
||||
QRegion paintedRegion() const;
|
||||
bool isVisible() const { return !requested_region.isEmpty(); }
|
||||
bool isPartiallyObscured() const { return requested_region != allocatedRegion(); }
|
||||
bool isFullyObscured() const { return allocatedRegion().isEmpty(); }
|
||||
|
||||
enum State { NoState, Hidden, Showing, Visible, Hiding, Raising, Lowering, Moving, ChangingGeometry, Destroyed };
|
||||
State state() const;
|
||||
Qt::WindowFlags windowFlags() const;
|
||||
QRegion dirtyOnScreen() const;
|
||||
|
||||
void raise();
|
||||
void lower();
|
||||
void show();
|
||||
void hide();
|
||||
void setActiveWindow();
|
||||
|
||||
bool isOpaque() const {return opaque && _opacity == 255;}
|
||||
uint opacity() const { return _opacity; }
|
||||
|
||||
QWSWindowSurface* windowSurface() const { return surface; }
|
||||
|
||||
private:
|
||||
bool hidden() const { return requested_region.isEmpty(); }
|
||||
bool forClient(const QWSClient* cl) const { return cl==c; }
|
||||
|
||||
void setName(const QString &n);
|
||||
void setCaption(const QString &c);
|
||||
|
||||
void focus(bool get);
|
||||
int focusPriority() const { return last_focus_time; }
|
||||
void operation(QWSWindowOperationEvent::Operation o);
|
||||
void shuttingDown() { last_focus_time=0; }
|
||||
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
QRegion directPaintRegion() const;
|
||||
inline void setDirectPaintRegion(const QRegion &topmost);
|
||||
#endif
|
||||
inline void setAllocatedRegion(const QRegion ®ion);
|
||||
|
||||
void createSurface(const QString &key, const QByteArray &data);
|
||||
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
void startEmbed(QWSWindow *window);
|
||||
void stopEmbed(QWSWindow *window);
|
||||
#endif
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString rgnName;
|
||||
QString rgnCaption;
|
||||
bool modified;
|
||||
bool onTop;
|
||||
QWSClient* c;
|
||||
QRegion requested_region;
|
||||
QRegion exposed;
|
||||
int last_focus_time;
|
||||
QWSWindowSurface *surface;
|
||||
uint _opacity;
|
||||
bool opaque;
|
||||
QWSWindowPrivate *d;
|
||||
#ifdef QT3_SUPPORT
|
||||
inline QT3_SUPPORT QRegion requested() const { return requested_region; }
|
||||
// inline QT3_SUPPORT QRegion allocation() const { return allocated_region; }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
class QWSSoundServer;
|
||||
#ifdef QT_USE_OLD_QWS_SOUND
|
||||
class QWSSoundServerData;
|
||||
|
||||
class Q_GUI_EXPORT QWSSoundServer : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSSoundServer(QObject* parent);
|
||||
~QWSSoundServer();
|
||||
void playFile(const QString& filename);
|
||||
private Q_SLOTS:
|
||||
void feedDevice(int fd);
|
||||
private:
|
||||
QWSSoundServerData* d;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Class: QWSServer
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
class QWSMouseHandler;
|
||||
struct QWSCommandStruct;
|
||||
class QWSServerPrivate;
|
||||
class QWSServer;
|
||||
|
||||
extern Q_GUI_EXPORT QWSServer *qwsServer;
|
||||
|
||||
class Q_GUI_EXPORT QWSServer : public QObject
|
||||
{
|
||||
friend class QCopChannel;
|
||||
friend class QWSMouseHandler;
|
||||
friend class QWSWindow;
|
||||
friend class QWSDisplay;
|
||||
friend class QWSInputMethod;
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QWSServer)
|
||||
public:
|
||||
explicit QWSServer(int flags = 0, QObject *parent=0);
|
||||
#ifdef QT3_SUPPORT
|
||||
QT3_SUPPORT_CONSTRUCTOR QWSServer(int flags, QObject *parent, const char *name);
|
||||
#endif
|
||||
~QWSServer();
|
||||
enum ServerFlags { DisableKeyboard = 0x01,
|
||||
DisableMouse = 0x02 };
|
||||
|
||||
static void sendKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
|
||||
bool isPress, bool autoRepeat);
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
static void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
|
||||
bool isPress, bool autoRepeat);
|
||||
#endif
|
||||
|
||||
static QWSServer* instance() { return qwsServer; }
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
#ifdef QT3_SUPPORT
|
||||
enum IMState { IMCompose, IMEnd, IMStart = IMCompose };
|
||||
#endif
|
||||
enum IMMouse { MousePress, MouseRelease, MouseMove, MouseOutside }; //MouseMove reserved but not used
|
||||
void sendIMEvent(const QInputMethodEvent*);
|
||||
void sendIMQuery(int property);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
class KeyboardFilter
|
||||
{
|
||||
public:
|
||||
virtual ~KeyboardFilter() {}
|
||||
virtual bool filter(int unicode, int keycode, int modifiers,
|
||||
bool isPress, bool autoRepeat)=0;
|
||||
};
|
||||
static void addKeyboardFilter(KeyboardFilter *f);
|
||||
static void removeKeyboardFilter();
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
static void setCurrentInputMethod(QWSInputMethod *im);
|
||||
static void resetInputMethod();
|
||||
#endif
|
||||
|
||||
static void setDefaultMouse(const char *);
|
||||
static void setDefaultKeyboard(const char *);
|
||||
static void setMaxWindowRect(const QRect&);
|
||||
static void sendMouseEvent(const QPoint& pos, int state, int wheel = 0);
|
||||
|
||||
static void setBackground(const QBrush &);
|
||||
#ifdef QT3_SUPPORT
|
||||
static QT3_SUPPORT void setDesktopBackground(const QImage &img);
|
||||
static QT3_SUPPORT void setDesktopBackground(const QColor &);
|
||||
#endif
|
||||
static QWSMouseHandler *mouseHandler();
|
||||
static const QList<QWSMouseHandler*>& mouseHandlers();
|
||||
static void setMouseHandler(QWSMouseHandler*);
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
static QWSKeyboardHandler* keyboardHandler();
|
||||
static void setKeyboardHandler(QWSKeyboardHandler* kh);
|
||||
#endif
|
||||
QWSWindow *windowAt(const QPoint& pos);
|
||||
|
||||
const QList<QWSWindow*> &clientWindows();
|
||||
|
||||
void openMouse();
|
||||
void closeMouse();
|
||||
void suspendMouse();
|
||||
void resumeMouse();
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
void openKeyboard();
|
||||
void closeKeyboard();
|
||||
#endif
|
||||
|
||||
static void setScreenSaver(QWSScreenSaver*);
|
||||
static void setScreenSaverIntervals(int* ms);
|
||||
static void setScreenSaverInterval(int);
|
||||
static void setScreenSaverBlockLevel(int);
|
||||
static bool screenSaverActive();
|
||||
static void screenSaverActivate(bool);
|
||||
|
||||
// the following are internal.
|
||||
void refresh();
|
||||
void refresh(QRegion &);
|
||||
|
||||
void enablePainting(bool);
|
||||
static void processEventQueue();
|
||||
static QList<QWSInternalWindowInfo*> * windowList();
|
||||
|
||||
void sendPropertyNotifyEvent(int property, int state);
|
||||
|
||||
static QPoint mousePosition;
|
||||
|
||||
static void startup(int flags);
|
||||
static void closedown();
|
||||
|
||||
static void beginDisplayReconfigure();
|
||||
static void endDisplayReconfigure();
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
static void setCursorVisible(bool);
|
||||
static bool isCursorVisible();
|
||||
#endif
|
||||
|
||||
const QBrush &backgroundBrush() const;
|
||||
|
||||
enum WindowEvent { Create=0x0001, Destroy=0x0002, Hide=0x0004, Show=0x0008,
|
||||
Raise=0x0010, Lower=0x0020, Geometry=0x0040, Active = 0x0080,
|
||||
Name=0x0100 };
|
||||
|
||||
Q_SIGNALS:
|
||||
void windowEvent(QWSWindow *w, QWSServer::WindowEvent e);
|
||||
|
||||
#ifndef QT_NO_COP
|
||||
void newChannel(const QString& channel);
|
||||
void removedChannel(const QString& channel);
|
||||
|
||||
#endif
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
void markedText(const QString &);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *e);
|
||||
|
||||
private:
|
||||
friend class QApplicationPrivate;
|
||||
void updateWindowRegions() const;
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
#ifndef QT_NO_QWS_KEYBOARD
|
||||
static inline QT3_SUPPORT void setKeyboardFilter(QWSServer::KeyboardFilter *f)
|
||||
{ if (f) addKeyboardFilter(f); else removeKeyboardFilter(); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_clientClosed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_doClient())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_deleteWindowsLater())
|
||||
#endif
|
||||
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_screenSaverWake())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_screenSaverSleep())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_screenSaverTimeout())
|
||||
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
class Q_GUI_EXPORT QWSInputMethod : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWSInputMethod();
|
||||
virtual ~QWSInputMethod();
|
||||
|
||||
enum UpdateType {Update, FocusIn, FocusOut, Reset, Destroyed};
|
||||
|
||||
virtual bool filter(int unicode, int keycode, int modifiers,
|
||||
bool isPress, bool autoRepeat);
|
||||
|
||||
virtual bool filter(const QPoint &, int state, int wheel);
|
||||
|
||||
virtual void reset();
|
||||
virtual void updateHandler(int type);
|
||||
virtual void mouseHandler(int pos, int state);
|
||||
virtual void queryResponse(int property, const QVariant&);
|
||||
|
||||
protected:
|
||||
uint setInputResolution(bool isHigh);
|
||||
uint inputResolutionShift() const;
|
||||
// needed for required transform
|
||||
void sendMouseEvent(const QPoint &pos, int state, int wheel);
|
||||
|
||||
void sendEvent(const QInputMethodEvent*);
|
||||
void sendPreeditString(const QString &preeditString, int cursorPosition, int selectionLength = 0);
|
||||
void sendCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
|
||||
void sendQuery(int property);
|
||||
|
||||
#ifdef QT3_SUPPORT
|
||||
inline void sendIMEvent(QWSServer::IMState, const QString& txt, int cpos, int selLen = 0);
|
||||
#endif
|
||||
private:
|
||||
bool mIResolution;
|
||||
};
|
||||
|
||||
inline void QWSInputMethod::sendEvent(const QInputMethodEvent *ime)
|
||||
{
|
||||
qwsServer->sendIMEvent(ime);
|
||||
}
|
||||
#ifdef QT3_SUPPORT
|
||||
inline void QWSInputMethod::sendIMEvent(QWSServer::IMState state, const QString& txt, int cpos, int selLen)
|
||||
{
|
||||
if (state == QWSServer::IMCompose) sendPreeditString(txt, cpos, selLen); else sendCommitString(txt);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void QWSInputMethod::sendQuery(int property)
|
||||
{
|
||||
qwsServer->sendIMQuery(property);
|
||||
}
|
||||
|
||||
// mouse events not inline as involve transformations.
|
||||
#endif // QT_NO_QWS_INPUTMETHODS
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Class: QWSClient
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
struct QWSMouseEvent;
|
||||
|
||||
typedef QMap<int, QWSCursor*> QWSCursorMap;
|
||||
|
||||
class QWSClientPrivate;
|
||||
class QWSCommand;
|
||||
class QWSConvertSelectionCommand;
|
||||
|
||||
class Q_GUI_EXPORT QWSClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QWSClient)
|
||||
public:
|
||||
QWSClient(QObject* parent, QWS_SOCK_BASE *, int id);
|
||||
~QWSClient();
|
||||
|
||||
int socket() const;
|
||||
|
||||
void setIdentity(const QString&);
|
||||
QString identity() const { return id; }
|
||||
|
||||
void sendEvent(QWSEvent* event);
|
||||
void sendConnectedEvent(const char *display_spec);
|
||||
void sendMaxWindowRectEvent(const QRect &rect);
|
||||
void sendPropertyNotifyEvent(int property, int state);
|
||||
void sendPropertyReplyEvent(int property, int len, const char *data);
|
||||
void sendSelectionClearEvent(int windowid);
|
||||
void sendSelectionRequestEvent(QWSConvertSelectionCommand *cmd, int windowid);
|
||||
#ifndef QT_QWS_CLIENTBLIT
|
||||
void sendRegionEvent(int winid, QRegion rgn, int type);
|
||||
#else
|
||||
void sendRegionEvent(int winid, QRegion rgn, int type, int id = 0);
|
||||
#endif
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
void sendEmbedEvent(int winid, QWSEmbedEvent::Type type,
|
||||
const QRegion ®ion = QRegion());
|
||||
#endif
|
||||
QWSCommand* readMoreCommand();
|
||||
|
||||
int clientId() const { return cid; }
|
||||
|
||||
QWSCursorMap cursors; // cursors defined by this client
|
||||
Q_SIGNALS:
|
||||
void connectionClosed();
|
||||
void readyRead();
|
||||
private Q_SLOTS:
|
||||
void closeHandler();
|
||||
void errorHandler();
|
||||
|
||||
private:
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
friend class QWSWindow;
|
||||
void removeUnbufferedSurface();
|
||||
void addUnbufferedSurface();
|
||||
#endif
|
||||
|
||||
private:
|
||||
int socketDescriptor;
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
QWSSocket *csocket;
|
||||
#endif
|
||||
QWSCommand* command;
|
||||
uint isClosed : 1;
|
||||
QString id;
|
||||
int cid;
|
||||
|
||||
friend class QWSServerPrivate;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWINDOWSYSTEM_QWS_H
|
@ -1,609 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwscommand_qws_p.h"
|
||||
#include "qtransportauth_qws.h"
|
||||
#include "qtransportauth_qws_p.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
// #define QWSCOMMAND_DEBUG 1 // Uncomment to debug client/server communication
|
||||
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
# include <qdebug.h>
|
||||
# include "qfile.h"
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
// QWSHexDump -[ start ]---------------------------------------------
|
||||
# define QWSHEXDUMP_MAX 32
|
||||
class QWSHexDump
|
||||
{
|
||||
public:
|
||||
|
||||
QWSHexDump(const void *address, int len, int wrapAt = 16)
|
||||
: wrap(wrapAt), dataSize(len)
|
||||
{
|
||||
init();
|
||||
data = reinterpret_cast<const char*>(address);
|
||||
if (len < 0)
|
||||
dataSize = 0;
|
||||
}
|
||||
|
||||
QWSHexDump(const char *str, int len = -1, int wrapAt = 16)
|
||||
: wrap(wrapAt), dataSize(len)
|
||||
{
|
||||
init();
|
||||
data = str;
|
||||
if (len == -1)
|
||||
dataSize = str ? strlen(str) : 0;
|
||||
}
|
||||
|
||||
QWSHexDump(const QByteArray &array, int wrapAt = 16)
|
||||
: wrap(wrapAt)
|
||||
{
|
||||
init();
|
||||
data = array.data();
|
||||
dataSize = array.size();
|
||||
}
|
||||
|
||||
// Sets a customized prefix for the hexdump
|
||||
void setPrefix(const char *str) { prefix = str; }
|
||||
|
||||
// Sets number of bytes to cluster together
|
||||
void setClusterSize(uint num) { clustering = num; }
|
||||
|
||||
// Output hexdump to a text stream
|
||||
void intoTextStream(QTextStream &strm) {
|
||||
outstrm = &strm;
|
||||
hexDump();
|
||||
}
|
||||
|
||||
// Output hexdump to a QString
|
||||
QString toString();
|
||||
|
||||
protected:
|
||||
void init();
|
||||
void hexDump();
|
||||
void sideviewDump(int at);
|
||||
|
||||
private:
|
||||
uint wrap;
|
||||
uint clustering;
|
||||
uint dataSize;
|
||||
int dataWidth;
|
||||
const char *data;
|
||||
const char *prefix;
|
||||
bool dirty;
|
||||
|
||||
char sideviewLayout[QWSHEXDUMP_MAX + 1];
|
||||
char sideview[15];
|
||||
|
||||
QTextStream *outstrm;
|
||||
};
|
||||
|
||||
void QWSHexDump::init()
|
||||
{
|
||||
prefix = "> "; // Standard line prefix
|
||||
clustering = 2; // Word-size clustering by default
|
||||
if (wrap > QWSHEXDUMP_MAX) // No wider than QWSHexDump_MAX bytes
|
||||
wrap = QWSHEXDUMP_MAX;
|
||||
}
|
||||
|
||||
void QWSHexDump::hexDump()
|
||||
{
|
||||
*outstrm << '(' << dataSize << " bytes):\n" << prefix;
|
||||
sprintf(sideviewLayout, " [%%-%us]", wrap);
|
||||
dataWidth = (2 * wrap) + (wrap / clustering);
|
||||
|
||||
dirty = false;
|
||||
uint wrapIndex = 0;
|
||||
for (uint i = 0; i < dataSize; i++) {
|
||||
uint c = static_cast<uchar>(data[i]);
|
||||
sideview[wrapIndex = i%wrap] = isprint(c) ? c : '.';
|
||||
|
||||
if (wrapIndex && (wrapIndex % clustering == 0))
|
||||
*outstrm << ' ';
|
||||
|
||||
outstrm->setFieldWidth(2);
|
||||
outstrm->setPadChar('0');
|
||||
outstrm->setNumberFlags( QTextStream::ShowBase );
|
||||
*outstrm << hex << c;
|
||||
dirty = true;
|
||||
|
||||
if (wrapIndex == wrap-1) {
|
||||
sideviewDump(wrapIndex);
|
||||
wrapIndex = 0;
|
||||
if (i+1 < dataSize)
|
||||
*outstrm << endl << prefix;
|
||||
}
|
||||
|
||||
}
|
||||
sideviewDump(wrapIndex);
|
||||
}
|
||||
|
||||
void QWSHexDump::sideviewDump(int at)
|
||||
{
|
||||
if (dirty) {
|
||||
dirty = false;
|
||||
++at;
|
||||
sideview[at] = '\0';
|
||||
int currentWidth = (2 * at) + (at / clustering) - (at%clustering?0:1);
|
||||
int missing = qMax(dataWidth - currentWidth, 0);
|
||||
while (missing--)
|
||||
*outstrm << ' ';
|
||||
|
||||
*outstrm << " [";
|
||||
outstrm->setPadChar(' ');
|
||||
outstrm->setFieldWidth(wrap);
|
||||
outstrm->setFieldAlignment( QTextStream::AlignLeft );
|
||||
*outstrm << sideview;
|
||||
*outstrm << ']';
|
||||
}
|
||||
}
|
||||
|
||||
// Output hexdump to a QString
|
||||
QString QWSHexDump::toString() {
|
||||
QString result;
|
||||
QTextStream strm(&result, QFile::WriteOnly);
|
||||
outstrm = &strm;
|
||||
hexDump();
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug &operator<<(QDebug &dbg, QWSHexDump *hd) {
|
||||
if (!hd)
|
||||
return dbg << "QWSHexDump(0x0)";
|
||||
QString result = hd->toString();
|
||||
dbg.nospace() << result;
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
// GCC & Intel wont handle references here
|
||||
QDebug operator<<(QDebug dbg, QWSHexDump hd) {
|
||||
return dbg << &hd;
|
||||
}
|
||||
#endif
|
||||
// QWSHexDump -[ end ]-----------------------------------------------
|
||||
|
||||
|
||||
QDebug &operator<<(QDebug &dbg, QWSCommand::Type tp)
|
||||
{
|
||||
dbg << qws_getCommandTypeString( tp );
|
||||
return dbg;
|
||||
}
|
||||
|
||||
#define N_EVENTS 19
|
||||
const char * eventNames[N_EVENTS] = {
|
||||
"NoEvent",
|
||||
"Connected",
|
||||
"Mouse", "Focus", "Key",
|
||||
"Region",
|
||||
"Creation",
|
||||
"PropertyNotify",
|
||||
"PropertyReply",
|
||||
"SelectionClear",
|
||||
"SelectionRequest",
|
||||
"SelectionNotify",
|
||||
"MaxWindowRect",
|
||||
"QCopMessage",
|
||||
"WindowOperation",
|
||||
"IMEvent",
|
||||
"IMQuery",
|
||||
"IMInit",
|
||||
"Font"
|
||||
};
|
||||
|
||||
class QWSServer;
|
||||
extern QWSServer *qwsServer;
|
||||
#endif
|
||||
|
||||
const char *qws_getCommandTypeString( QWSCommand::Type tp )
|
||||
{
|
||||
const char *typeStr;
|
||||
switch(tp) {
|
||||
case QWSCommand::Create:
|
||||
typeStr = "Create";
|
||||
break;
|
||||
case QWSCommand::Shutdown:
|
||||
typeStr = "Shutdown";
|
||||
break;
|
||||
case QWSCommand::Region:
|
||||
typeStr = "Region";
|
||||
break;
|
||||
case QWSCommand::RegionMove:
|
||||
typeStr = "RegionMove";
|
||||
break;
|
||||
case QWSCommand::RegionDestroy:
|
||||
typeStr = "RegionDestroy";
|
||||
break;
|
||||
case QWSCommand::SetProperty:
|
||||
typeStr = "SetProperty";
|
||||
break;
|
||||
case QWSCommand::AddProperty:
|
||||
typeStr = "AddProperty";
|
||||
break;
|
||||
case QWSCommand::RemoveProperty:
|
||||
typeStr = "RemoveProperty";
|
||||
break;
|
||||
case QWSCommand::GetProperty:
|
||||
typeStr = "GetProperty";
|
||||
break;
|
||||
case QWSCommand::SetSelectionOwner:
|
||||
typeStr = "SetSelectionOwner";
|
||||
break;
|
||||
case QWSCommand::ConvertSelection:
|
||||
typeStr = "ConvertSelection";
|
||||
break;
|
||||
case QWSCommand::RequestFocus:
|
||||
typeStr = "RequestFocus";
|
||||
break;
|
||||
case QWSCommand::ChangeAltitude:
|
||||
typeStr = "ChangeAltitude";
|
||||
break;
|
||||
case QWSCommand::SetOpacity:
|
||||
typeStr = "SetOpacity";
|
||||
break;
|
||||
case QWSCommand::DefineCursor:
|
||||
typeStr = "DefineCursor";
|
||||
break;
|
||||
case QWSCommand::SelectCursor:
|
||||
typeStr = "SelectCursor";
|
||||
break;
|
||||
case QWSCommand::PositionCursor:
|
||||
typeStr = "PositionCursor";
|
||||
break;
|
||||
case QWSCommand::GrabMouse:
|
||||
typeStr = "GrabMouse";
|
||||
break;
|
||||
case QWSCommand::PlaySound:
|
||||
typeStr = "PlaySound";
|
||||
break;
|
||||
case QWSCommand::QCopRegisterChannel:
|
||||
typeStr = "QCopRegisterChannel";
|
||||
break;
|
||||
case QWSCommand::QCopSend:
|
||||
typeStr = "QCopSend";
|
||||
break;
|
||||
case QWSCommand::RegionName:
|
||||
typeStr = "RegionName";
|
||||
break;
|
||||
case QWSCommand::Identify:
|
||||
typeStr = "Identify";
|
||||
break;
|
||||
case QWSCommand::GrabKeyboard:
|
||||
typeStr = "GrabKeyboard";
|
||||
break;
|
||||
case QWSCommand::RepaintRegion:
|
||||
typeStr = "RepaintRegion";
|
||||
break;
|
||||
case QWSCommand::IMMouse:
|
||||
typeStr = "IMMouse";
|
||||
break;
|
||||
case QWSCommand::IMUpdate:
|
||||
typeStr = "IMUpdate";
|
||||
break;
|
||||
case QWSCommand::IMResponse:
|
||||
typeStr = "IMResponse";
|
||||
break;
|
||||
case QWSCommand::Font:
|
||||
typeStr = "Font";
|
||||
break;
|
||||
case QWSCommand::Unknown:
|
||||
default:
|
||||
typeStr = "Unknown";
|
||||
break;
|
||||
}
|
||||
return typeStr;
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Functions to read/write commands on/from a socket
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen,
|
||||
char *rawData, int rawLen)
|
||||
{
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
if (simpleLen) qDebug() << "WRITE simpleData " << QWSHexDump(simpleData, simpleLen);
|
||||
if (rawLen > 0) qDebug() << "WRITE rawData " << QWSHexDump(rawData, rawLen);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_SXE
|
||||
QTransportAuth *a = QTransportAuth::getInstance();
|
||||
// ###### as soon as public API can be modified get rid of horrible casts
|
||||
QIODevice *ad = a->passThroughByClient(reinterpret_cast<QWSClient*>(socket));
|
||||
if (ad)
|
||||
socket = ad;
|
||||
#endif
|
||||
|
||||
qws_write_uint(socket, type);
|
||||
|
||||
if (rawLen > MAX_COMMAND_SIZE) {
|
||||
qWarning("qws_write_command: Message of size %d too big. "
|
||||
"Truncated to %d", rawLen, MAX_COMMAND_SIZE);
|
||||
rawLen = MAX_COMMAND_SIZE;
|
||||
}
|
||||
|
||||
qws_write_uint(socket, rawLen == -1 ? 0 : rawLen);
|
||||
|
||||
if (simpleData && simpleLen)
|
||||
socket->write(simpleData, simpleLen);
|
||||
|
||||
if (rawLen && rawData)
|
||||
socket->write(rawData, rawLen);
|
||||
}
|
||||
|
||||
/*
|
||||
command format: [type][rawLen][simpleData][rawData]
|
||||
type is already read when entering this function
|
||||
*/
|
||||
|
||||
bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen,
|
||||
char *&rawData, int &rawLen, int &bytesRead)
|
||||
{
|
||||
|
||||
// read rawLen
|
||||
if (rawLen == -1) {
|
||||
rawLen = qws_read_uint(socket);
|
||||
if (rawLen == -1)
|
||||
return false;
|
||||
}
|
||||
|
||||
// read simpleData, assumes socket is capable of buffering all the data
|
||||
if (simpleLen && !rawData) {
|
||||
if (socket->bytesAvailable() < uint(simpleLen))
|
||||
return false;
|
||||
int tmp = socket->read(simpleData, simpleLen);
|
||||
Q_ASSERT(tmp == simpleLen);
|
||||
Q_UNUSED(tmp);
|
||||
}
|
||||
|
||||
if (rawLen > MAX_COMMAND_SIZE) {
|
||||
socket->close();
|
||||
qWarning("qws_read_command: Won't read command of length %d, "
|
||||
"connection closed.", rawLen);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read rawData
|
||||
if (rawLen && !rawData) {
|
||||
rawData = new char[rawLen];
|
||||
bytesRead = 0;
|
||||
}
|
||||
if (bytesRead < rawLen && socket->bytesAvailable())
|
||||
bytesRead += socket->read(rawData + bytesRead, rawLen - bytesRead);
|
||||
|
||||
return (bytesRead == rawLen);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* QWSCommand base class - only use derived classes from that
|
||||
*
|
||||
*********************************************************************/
|
||||
QWSProtocolItem::~QWSProtocolItem() {
|
||||
if (deleteRaw)
|
||||
delete []rawDataPtr;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
void QWSProtocolItem::write(QIODevice *s) {
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
if (!qwsServer)
|
||||
qDebug() << "QWSProtocolItem::write sending type " << static_cast<QWSCommand::Type>(type);
|
||||
else
|
||||
qDebug() << "QWSProtocolItem::write sending event " << (type < N_EVENTS ? eventNames[type] : "unknown");
|
||||
#endif
|
||||
qws_write_command(s, type, simpleDataPtr, simpleLen, rawDataPtr, rawLen);
|
||||
}
|
||||
|
||||
bool QWSProtocolItem::read(QIODevice *s) {
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
QLatin1String reread( (rawLen == -1) ? "" : "REREAD");
|
||||
if (qwsServer)
|
||||
qDebug() << "QWSProtocolItem::read reading type " << static_cast<QWSCommand::Type>(type) << reread;
|
||||
else
|
||||
qDebug() << "QWSProtocolItem::read reading event " << (type < N_EVENTS ? eventNames[type] : "unknown") << reread;
|
||||
//qDebug("QWSProtocolItem::read reading event %s", type < N_EVENTS ? eventNames[type] : "unknown");
|
||||
#endif
|
||||
bool b = qws_read_command(s, simpleDataPtr, simpleLen, rawDataPtr, rawLen, bytesRead);
|
||||
if (b) {
|
||||
setData(rawDataPtr, rawLen, false);
|
||||
deleteRaw = true;
|
||||
}
|
||||
#ifdef QWSCOMMAND_DEBUG
|
||||
else
|
||||
{
|
||||
qDebug() << "error in reading command " << static_cast<QWSCommand::Type>(type);
|
||||
}
|
||||
#endif
|
||||
return b;
|
||||
}
|
||||
#endif // QT_NO_QWS_MULTIPROCESS
|
||||
|
||||
void QWSProtocolItem::copyFrom(const QWSProtocolItem *item) {
|
||||
if (this == item)
|
||||
return;
|
||||
simpleLen = item->simpleLen;
|
||||
memcpy(simpleDataPtr, item->simpleDataPtr, simpleLen);
|
||||
setData(item->rawDataPtr, item->rawLen);
|
||||
}
|
||||
|
||||
void QWSProtocolItem::setData(const char *data, int len, bool allocateMem) {
|
||||
if (deleteRaw)
|
||||
delete [] rawDataPtr;
|
||||
if (!data || len <= 0) {
|
||||
rawDataPtr = 0;
|
||||
rawLen = 0;
|
||||
return;
|
||||
}
|
||||
if (allocateMem) {
|
||||
rawDataPtr = new char[len];
|
||||
memcpy(rawDataPtr, data, len);
|
||||
deleteRaw = true;
|
||||
} else {
|
||||
rawDataPtr = const_cast<char *>(data);
|
||||
deleteRaw = false;
|
||||
}
|
||||
rawLen = len;
|
||||
}
|
||||
|
||||
QWSCommand *QWSCommand::factory(int type)
|
||||
{
|
||||
QWSCommand *command = 0;
|
||||
switch (type) {
|
||||
case QWSCommand::Create:
|
||||
command = new QWSCreateCommand;
|
||||
break;
|
||||
case QWSCommand::Shutdown:
|
||||
command = new QWSCommand(type, 0, 0);
|
||||
break;
|
||||
case QWSCommand::Region:
|
||||
command = new QWSRegionCommand;
|
||||
break;
|
||||
case QWSCommand::RegionMove:
|
||||
command = new QWSRegionMoveCommand;
|
||||
break;
|
||||
case QWSCommand::RegionDestroy:
|
||||
command = new QWSRegionDestroyCommand;
|
||||
break;
|
||||
case QWSCommand::AddProperty:
|
||||
command = new QWSAddPropertyCommand;
|
||||
break;
|
||||
case QWSCommand::SetProperty:
|
||||
command = new QWSSetPropertyCommand;
|
||||
break;
|
||||
case QWSCommand::RemoveProperty:
|
||||
command = new QWSRemovePropertyCommand;
|
||||
break;
|
||||
case QWSCommand::GetProperty:
|
||||
command = new QWSGetPropertyCommand;
|
||||
break;
|
||||
case QWSCommand::SetSelectionOwner:
|
||||
command = new QWSSetSelectionOwnerCommand;
|
||||
break;
|
||||
case QWSCommand::RequestFocus:
|
||||
command = new QWSRequestFocusCommand;
|
||||
break;
|
||||
case QWSCommand::ChangeAltitude:
|
||||
command = new QWSChangeAltitudeCommand;
|
||||
break;
|
||||
case QWSCommand::SetOpacity:
|
||||
command = new QWSSetOpacityCommand;
|
||||
break;
|
||||
case QWSCommand::DefineCursor:
|
||||
command = new QWSDefineCursorCommand;
|
||||
break;
|
||||
case QWSCommand::SelectCursor:
|
||||
command = new QWSSelectCursorCommand;
|
||||
break;
|
||||
case QWSCommand::GrabMouse:
|
||||
command = new QWSGrabMouseCommand;
|
||||
break;
|
||||
case QWSCommand::GrabKeyboard:
|
||||
command = new QWSGrabKeyboardCommand;
|
||||
break;
|
||||
#ifndef QT_NO_SOUND
|
||||
case QWSCommand::PlaySound:
|
||||
command = new QWSPlaySoundCommand;
|
||||
break;
|
||||
#endif
|
||||
#ifndef QT_NO_COP
|
||||
case QWSCommand::QCopRegisterChannel:
|
||||
command = new QWSQCopRegisterChannelCommand;
|
||||
break;
|
||||
case QWSCommand::QCopSend:
|
||||
command = new QWSQCopSendCommand;
|
||||
break;
|
||||
#endif
|
||||
case QWSCommand::RegionName:
|
||||
command = new QWSRegionNameCommand;
|
||||
break;
|
||||
case QWSCommand::Identify:
|
||||
command = new QWSIdentifyCommand;
|
||||
break;
|
||||
case QWSCommand::RepaintRegion:
|
||||
command = new QWSRepaintRegionCommand;
|
||||
break;
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
case QWSCommand::IMUpdate:
|
||||
command = new QWSIMUpdateCommand;
|
||||
break;
|
||||
|
||||
case QWSCommand::IMMouse:
|
||||
command = new QWSIMMouseCommand;
|
||||
break;
|
||||
|
||||
case QWSCommand::IMResponse:
|
||||
command = new QWSIMResponseCommand;
|
||||
break;
|
||||
#endif
|
||||
case QWSCommand::PositionCursor:
|
||||
command = new QWSPositionCursorCommand;
|
||||
break;
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
case QWSCommand::Embed:
|
||||
command = new QWSEmbedCommand;
|
||||
break;
|
||||
#endif
|
||||
case QWSCommand::Font:
|
||||
command = new QWSFontCommand;
|
||||
break;
|
||||
case QWSCommand::ScreenTransform:
|
||||
command = new QWSScreenTransformCommand;
|
||||
break;
|
||||
default:
|
||||
qWarning("QWSCommand::factory : Type error - got %08x!", type);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,851 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSCOMMAND_QWS_P_H
|
||||
#define QWSCOMMAND_QWS_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.
|
||||
//
|
||||
|
||||
// When reading commands "off the wire" in the server, the rawLen is read
|
||||
// and then that many bytes are allocated. If the rawLen is corrupted (or
|
||||
// the protocol is being attacked) too many bytes can be allocated. Set
|
||||
// a hard limit here for security.
|
||||
#define MAX_COMMAND_SIZE (16 * 1024)
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtGui/qwsutils_qws.h>
|
||||
#include <QtGui/qfont.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtGui/qregion.h>
|
||||
#include <QtCore/qvector.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtGui/qwsevent_qws.h>
|
||||
#include "qwsprotocolitem_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QRect;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Functions to read/write commands on/from a socket
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen, char *rawData, int rawLen);
|
||||
bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen, char *&rawData, int &rawLen, int &bytesRead);
|
||||
#endif
|
||||
|
||||
struct QWSCommand : QWSProtocolItem
|
||||
{
|
||||
QWSCommand(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}
|
||||
|
||||
enum Type {
|
||||
Unknown = 0,
|
||||
Create,
|
||||
Shutdown,
|
||||
Region,
|
||||
RegionMove,
|
||||
RegionDestroy,
|
||||
SetProperty,
|
||||
AddProperty,
|
||||
RemoveProperty,
|
||||
GetProperty,
|
||||
SetSelectionOwner,
|
||||
ConvertSelection,
|
||||
RequestFocus,
|
||||
ChangeAltitude,
|
||||
SetOpacity,
|
||||
DefineCursor,
|
||||
SelectCursor,
|
||||
PositionCursor,
|
||||
GrabMouse,
|
||||
PlaySound,
|
||||
QCopRegisterChannel,
|
||||
QCopSend,
|
||||
RegionName,
|
||||
Identify,
|
||||
GrabKeyboard,
|
||||
RepaintRegion,
|
||||
IMMouse,
|
||||
IMUpdate,
|
||||
IMResponse,
|
||||
Embed,
|
||||
Font,
|
||||
ScreenTransform
|
||||
};
|
||||
static QWSCommand *factory(int type);
|
||||
};
|
||||
|
||||
const char *qws_getCommandTypeString( QWSCommand::Type tp );
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
class QDebug;
|
||||
QDebug &operator<<(QDebug &dbg, QWSCommand::Type tp);
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Commands
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
struct QWSIdentifyCommand : public QWSCommand
|
||||
{
|
||||
QWSIdentifyCommand() :
|
||||
QWSCommand(QWSCommand::Identify,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData))
|
||||
{
|
||||
simpleData.idLen = 0;
|
||||
simpleData.idLock = -1;
|
||||
}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
if ( simpleData.idLen > MAX_COMMAND_SIZE )
|
||||
{
|
||||
qWarning( "Identify command - name length %d - too big!", simpleData.idLen );
|
||||
simpleData.idLen = MAX_COMMAND_SIZE;
|
||||
}
|
||||
if ( simpleData.idLen * int(sizeof(QChar)) > len )
|
||||
{
|
||||
qWarning( "Identify command - name length %d - buffer size %d - buffer overrun!", simpleData.idLen, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
id = QString(reinterpret_cast<const QChar*>(d), simpleData.idLen);
|
||||
}
|
||||
}
|
||||
|
||||
void setId(const QString& i, int lock)
|
||||
{
|
||||
id = i;
|
||||
simpleData.idLen = id.length();
|
||||
simpleData.idLock = lock;
|
||||
setData(reinterpret_cast<const char*>(id.unicode()), simpleData.idLen*2, true);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int idLen;
|
||||
int idLock;
|
||||
} simpleData;
|
||||
QString id;
|
||||
};
|
||||
|
||||
struct QWSCreateCommand : public QWSCommand
|
||||
{
|
||||
QWSCreateCommand(int n = 1) :
|
||||
QWSCommand(QWSCommand::Create, sizeof(count),
|
||||
reinterpret_cast<char *>(&count)), count(n) {}
|
||||
int count;
|
||||
};
|
||||
|
||||
struct QWSRegionNameCommand : public QWSCommand
|
||||
{
|
||||
QWSRegionNameCommand() :
|
||||
QWSCommand(QWSCommand::RegionName,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
if ( simpleData.nameLen > MAX_COMMAND_SIZE )
|
||||
{
|
||||
qWarning( "region name command - name length too big!" );
|
||||
simpleData.nameLen = MAX_COMMAND_SIZE;
|
||||
}
|
||||
if ( simpleData.captionLen > MAX_COMMAND_SIZE )
|
||||
{
|
||||
qWarning( "region name command - caption length too big!" );
|
||||
simpleData.captionLen = MAX_COMMAND_SIZE;
|
||||
}
|
||||
if ( simpleData.nameLen + simpleData.captionLen > len )
|
||||
{
|
||||
qWarning( "region name command - name length %d - caption length %d - buffer size %d - buffer overrun!",
|
||||
simpleData.nameLen, simpleData.captionLen, len );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
name = QString(reinterpret_cast<const QChar*>(d), simpleData.nameLen/2);
|
||||
d += simpleData.nameLen;
|
||||
caption = QString(reinterpret_cast<const QChar*>(d), simpleData.captionLen/2);
|
||||
}
|
||||
}
|
||||
|
||||
void setName(const QString& n, const QString &c)
|
||||
{
|
||||
name = n;
|
||||
caption = c;
|
||||
int l = simpleData.nameLen = name.length()*2;
|
||||
l += simpleData.captionLen = caption.length()*2;
|
||||
char *d = new char[l];
|
||||
memcpy(d, name.unicode(), simpleData.nameLen);
|
||||
memcpy(d+simpleData.nameLen, caption.unicode(), simpleData.captionLen);
|
||||
setData(d, l, true);
|
||||
delete[] d;
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int nameLen;
|
||||
int captionLen;
|
||||
} simpleData;
|
||||
QString name;
|
||||
QString caption;
|
||||
};
|
||||
|
||||
struct QWSRegionCommand : public QWSCommand
|
||||
{
|
||||
QWSRegionCommand() :
|
||||
QWSCommand(QWSCommand::Region, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
if( simpleData.nrectangles * int(sizeof(QRect)) + simpleData.surfacekeylength * int(sizeof(QChar)) + simpleData.surfacedatalength * int(sizeof(char)) > len )
|
||||
{
|
||||
qWarning( "region command - rectangle count %d - surface key length %d - region data size %d - buffer size %d - buffer overrun!",
|
||||
simpleData.nrectangles, simpleData.surfacekeylength, simpleData.surfacedatalength, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
char *ptr = rawDataPtr;
|
||||
|
||||
region.setRects(reinterpret_cast<QRect*>(ptr), simpleData.nrectangles);
|
||||
ptr += simpleData.nrectangles * sizeof(QRect);
|
||||
|
||||
surfaceKey = QString(reinterpret_cast<QChar*>(ptr),
|
||||
simpleData.surfacekeylength);
|
||||
ptr += simpleData.surfacekeylength * sizeof(QChar);
|
||||
|
||||
surfaceData = QByteArray(ptr, simpleData.surfacedatalength);
|
||||
}
|
||||
}
|
||||
|
||||
void setData(int id, const QString &key, const QByteArray &data,
|
||||
const QRegion ®)
|
||||
{
|
||||
surfaceKey = key;
|
||||
surfaceData = data;
|
||||
region = reg;
|
||||
|
||||
const QVector<QRect> rects = reg.rects();
|
||||
|
||||
simpleData.windowid = id;
|
||||
simpleData.surfacekeylength = key.size();
|
||||
simpleData.surfacedatalength = data.size();
|
||||
simpleData.nrectangles = rects.count();
|
||||
|
||||
QVarLengthArray<char, 256> buffer;
|
||||
buffer.append(reinterpret_cast<const char*>(rects.constData()),
|
||||
rects.count() * sizeof(QRect));
|
||||
buffer.append(reinterpret_cast<const char*>(key.constData()),
|
||||
key.size() * sizeof(QChar));
|
||||
buffer.append(data, data.size());
|
||||
|
||||
QWSCommand::setData(buffer.constData(), buffer.size(), true);
|
||||
}
|
||||
|
||||
/* XXX this will pad out in a compiler dependent way,
|
||||
should move nrectangles to before windowtype, and
|
||||
add reserved bytes.
|
||||
Symptom will be valgrind reported uninitialized memory usage
|
||||
*/
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int surfacekeylength;
|
||||
int surfacedatalength;
|
||||
int nrectangles;
|
||||
} simpleData;
|
||||
|
||||
QString surfaceKey;
|
||||
QByteArray surfaceData;
|
||||
QRegion region;
|
||||
};
|
||||
|
||||
struct QWSSetOpacityCommand : public QWSCommand
|
||||
{
|
||||
QWSSetOpacityCommand() :
|
||||
QWSCommand(QWSCommand::SetOpacity, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
uchar opacity;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSRegionMoveCommand : public QWSCommand
|
||||
{
|
||||
QWSRegionMoveCommand() :
|
||||
QWSCommand(QWSCommand::RegionMove, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int dx;
|
||||
int dy;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSRegionDestroyCommand : public QWSCommand
|
||||
{
|
||||
QWSRegionDestroyCommand() :
|
||||
QWSCommand(QWSCommand::RegionDestroy, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSRequestFocusCommand : public QWSCommand
|
||||
{
|
||||
QWSRequestFocusCommand() :
|
||||
QWSCommand(QWSCommand::RequestFocus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int flag;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSChangeAltitudeCommand : public QWSCommand
|
||||
{
|
||||
QWSChangeAltitudeCommand() :
|
||||
QWSCommand(QWSCommand::ChangeAltitude, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
enum Altitude {
|
||||
Lower = -1,
|
||||
Raise = 0,
|
||||
StaysOnTop = 1
|
||||
};
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
Altitude altitude;
|
||||
bool fixed;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct QWSAddPropertyCommand : public QWSCommand
|
||||
{
|
||||
QWSAddPropertyCommand() :
|
||||
QWSCommand(QWSCommand::AddProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid, property;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSSetPropertyCommand : public QWSCommand
|
||||
{
|
||||
QWSSetPropertyCommand() :
|
||||
QWSCommand(QWSCommand::SetProperty, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) { data = 0; }
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
data = rawDataPtr;
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid, property, mode;
|
||||
} simpleData;
|
||||
|
||||
char *data;
|
||||
};
|
||||
|
||||
struct QWSRepaintRegionCommand : public QWSCommand
|
||||
{
|
||||
QWSRepaintRegionCommand() :
|
||||
QWSCommand(QWSCommand::RepaintRegion, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
if( simpleData.nrectangles * int(sizeof(QRect)) > len )
|
||||
{
|
||||
qWarning( "repaint region command - region rectangle count %d - buffer size %d - buffer overrun",
|
||||
simpleData.nrectangles, len );
|
||||
|
||||
simpleData.nrectangles = len / sizeof(QRect);
|
||||
}
|
||||
rectangles = reinterpret_cast<QRect *>(rawDataPtr);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int windowFlags;
|
||||
bool opaque;
|
||||
int nrectangles;
|
||||
} simpleData;
|
||||
|
||||
QRect * rectangles;
|
||||
|
||||
};
|
||||
|
||||
struct QWSRemovePropertyCommand : public QWSCommand
|
||||
{
|
||||
QWSRemovePropertyCommand() :
|
||||
QWSCommand(QWSCommand::RemoveProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid, property;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSGetPropertyCommand : public QWSCommand
|
||||
{
|
||||
QWSGetPropertyCommand() :
|
||||
QWSCommand(QWSCommand::GetProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid, property;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSSetSelectionOwnerCommand : public QWSCommand
|
||||
{
|
||||
QWSSetSelectionOwnerCommand() :
|
||||
QWSCommand(QWSCommand::SetSelectionOwner,
|
||||
sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int hour, minute, sec, ms; // time
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSConvertSelectionCommand : public QWSCommand
|
||||
{
|
||||
QWSConvertSelectionCommand() :
|
||||
QWSCommand(QWSCommand::ConvertSelection,
|
||||
sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int requestor; // requestor window of the selection
|
||||
int selection; // property on requestor into which the selection should be stored
|
||||
int mimeTypes; // property ion requestor in which the mimetypes, in which the selection may be, are stored
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
struct QWSDefineCursorCommand : public QWSCommand
|
||||
{
|
||||
QWSDefineCursorCommand() :
|
||||
QWSCommand(QWSCommand::DefineCursor,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
data = reinterpret_cast<unsigned char *>(rawDataPtr);
|
||||
if (simpleData.height * ((simpleData.width+7) / 8) > len) {
|
||||
qWarning("define cursor command - width %d height %d- buffer size %d - buffer overrun",
|
||||
simpleData.width, simpleData.height, len );
|
||||
simpleData.width = simpleData.height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int width;
|
||||
int height;
|
||||
int hotX;
|
||||
int hotY;
|
||||
int id;
|
||||
} simpleData;
|
||||
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
struct QWSSelectCursorCommand : public QWSCommand
|
||||
{
|
||||
QWSSelectCursorCommand() :
|
||||
QWSCommand(QWSCommand::SelectCursor,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int id;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSPositionCursorCommand : public QWSCommand
|
||||
{
|
||||
QWSPositionCursorCommand() :
|
||||
QWSCommand(QWSCommand::PositionCursor,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int newX;
|
||||
int newY;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSGrabMouseCommand : public QWSCommand
|
||||
{
|
||||
QWSGrabMouseCommand() :
|
||||
QWSCommand(QWSCommand::GrabMouse,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
bool grab; // grab or ungrab?
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSGrabKeyboardCommand : public QWSCommand
|
||||
{
|
||||
QWSGrabKeyboardCommand() :
|
||||
QWSCommand(QWSCommand::GrabKeyboard,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
bool grab; // grab or ungrab?
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_SOUND
|
||||
struct QWSPlaySoundCommand : public QWSCommand
|
||||
{
|
||||
QWSPlaySoundCommand() :
|
||||
QWSCommand(QWSCommand::PlaySound,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
filename = QString(reinterpret_cast<QChar*>(rawDataPtr),len/2);
|
||||
}
|
||||
void setFileName(const QString& n)
|
||||
{
|
||||
setData(reinterpret_cast<const char*>(n.unicode()), n.length()*2, true);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
} simpleData;
|
||||
QString filename;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef QT_NO_COP
|
||||
struct QWSQCopRegisterChannelCommand : public QWSCommand
|
||||
{
|
||||
QWSQCopRegisterChannelCommand() :
|
||||
QWSCommand(QWSCommand::QCopRegisterChannel,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
if ( simpleData.chLen > MAX_COMMAND_SIZE )
|
||||
{
|
||||
qWarning( "Command channel name too large!" );
|
||||
simpleData.chLen = MAX_COMMAND_SIZE;
|
||||
}
|
||||
if( simpleData.chLen * int(sizeof(QChar)) > len )
|
||||
{
|
||||
qWarning( "register qcop channel command - channel name length %d - buffer size %d - buffer overrun!", simpleData.chLen, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
channel = QString(reinterpret_cast<const QChar*>(d), simpleData.chLen);
|
||||
}
|
||||
}
|
||||
|
||||
void setChannel(const QString& n)
|
||||
{
|
||||
channel = n;
|
||||
simpleData.chLen = channel.length();
|
||||
setData(reinterpret_cast<const char*>(channel.unicode()), simpleData.chLen*2, true);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int chLen;
|
||||
} simpleData;
|
||||
QString channel;
|
||||
};
|
||||
|
||||
struct QWSQCopSendCommand : public QWSCommand
|
||||
{
|
||||
QWSQCopSendCommand() :
|
||||
QWSCommand(QWSCommand::QCopSend,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
if( simpleData.clen * int(sizeof(QChar)) + simpleData.mlen * int(sizeof(QChar)) + simpleData.dlen * int(sizeof(char)) > len )
|
||||
{
|
||||
qWarning( "qcop send command - channel name length %d - message name length %d - data size %d - buffer size %d - buffer overrun!",
|
||||
simpleData.clen, simpleData.mlen, simpleData.dlen, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
const QChar *cd = reinterpret_cast<const QChar*>(d);
|
||||
channel = QString(cd,simpleData.clen); cd += simpleData.clen;
|
||||
message = QString(cd,simpleData.mlen);
|
||||
d += simpleData.clen*sizeof(QChar) + simpleData.mlen*sizeof(QChar);
|
||||
data = QByteArray(d, simpleData.dlen);
|
||||
}
|
||||
}
|
||||
|
||||
void setMessage(const QString &c, const QString &m,
|
||||
const QByteArray &data)
|
||||
{
|
||||
this->channel = c;
|
||||
this->message = m;
|
||||
this->data = data;
|
||||
simpleData.clen = c.length();
|
||||
simpleData.mlen = m.length();
|
||||
simpleData.dlen = data.size();
|
||||
int l = simpleData.clen*sizeof(QChar);
|
||||
l += simpleData.mlen*sizeof(QChar);
|
||||
l += simpleData.dlen;
|
||||
char *tmp = new char[l];
|
||||
char *d = tmp;
|
||||
memcpy(d, c.unicode(), simpleData.clen*sizeof(QChar));
|
||||
d += simpleData.clen*sizeof(QChar);
|
||||
memcpy(d, m.unicode(), simpleData.mlen*sizeof(QChar));
|
||||
d += simpleData.mlen*sizeof(QChar);
|
||||
memcpy(d, data.data(), simpleData.dlen);
|
||||
QWSCommand::setData(tmp, l, false);
|
||||
deleteRaw = true;
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int clen;
|
||||
int mlen;
|
||||
int dlen;
|
||||
} simpleData;
|
||||
QString channel;
|
||||
QString message;
|
||||
QByteArray data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
|
||||
struct QWSIMMouseCommand : public QWSCommand
|
||||
{
|
||||
QWSIMMouseCommand() :
|
||||
QWSCommand(QWSCommand::IMMouse,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int state;
|
||||
int index;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
|
||||
struct QWSIMResponseCommand : public QWSCommand
|
||||
{
|
||||
QWSIMResponseCommand() :
|
||||
QWSCommand(QWSCommand::IMResponse,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
QByteArray tmp = QByteArray::fromRawData(d, len);
|
||||
QDataStream s(tmp);
|
||||
s >> result;
|
||||
}
|
||||
|
||||
void setResult(const QVariant & v)
|
||||
{
|
||||
QByteArray tmp;
|
||||
QDataStream s(&tmp, QIODevice::WriteOnly);
|
||||
s << v;
|
||||
setData(tmp.data(), tmp.size(), true);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int property;
|
||||
} simpleData;
|
||||
|
||||
QVariant result;
|
||||
};
|
||||
|
||||
struct QWSIMUpdateCommand: public QWSCommand
|
||||
{
|
||||
QWSIMUpdateCommand() :
|
||||
QWSCommand(QWSCommand::IMUpdate,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int windowid;
|
||||
int type;
|
||||
int widgetid;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
struct QWSEmbedCommand : public QWSCommand
|
||||
{
|
||||
QWSEmbedCommand() : QWSCommand(QWSCommand::Embed,
|
||||
sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData))
|
||||
{}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true)
|
||||
{
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
if( simpleData.rects * int(sizeof(QRect)) > len )
|
||||
{
|
||||
qWarning( "embed command - region rectangle count %d - buffer size %d - buffer overrun!",
|
||||
simpleData.rects, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
region.setRects(reinterpret_cast<QRect*>(rawDataPtr),
|
||||
simpleData.rects);
|
||||
}
|
||||
}
|
||||
|
||||
void setData(WId embedder, WId embedded, QWSEmbedEvent::Type type,
|
||||
const QRegion reg = QRegion())
|
||||
{
|
||||
simpleData.embedder = embedder;
|
||||
simpleData.embedded = embedded;
|
||||
simpleData.type = type;
|
||||
|
||||
region = reg;
|
||||
const QVector<QRect> rects = reg.rects();
|
||||
simpleData.rects = rects.count();
|
||||
|
||||
QWSCommand::setData(reinterpret_cast<const char*>(rects.constData()),
|
||||
rects.count() * sizeof(QRect));
|
||||
}
|
||||
|
||||
struct {
|
||||
WId embedder;
|
||||
WId embedded;
|
||||
QWSEmbedEvent::Type type;
|
||||
int rects;
|
||||
} simpleData;
|
||||
|
||||
QRegion region;
|
||||
};
|
||||
#endif // QT_NO_QWSEMBEDWIDGET
|
||||
|
||||
struct QWSFontCommand : public QWSCommand
|
||||
{
|
||||
enum CommandType {
|
||||
StartedUsingFont,
|
||||
StoppedUsingFont
|
||||
};
|
||||
|
||||
QWSFontCommand() :
|
||||
QWSCommand(QWSCommand::Font,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem) {
|
||||
QWSCommand::setData(d, len, allocateMem);
|
||||
|
||||
fontName = QByteArray(d, len);
|
||||
}
|
||||
|
||||
void setFontName(const QByteArray &name)
|
||||
{
|
||||
setData(name.constData(), name.size(), true);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int type;
|
||||
} simpleData;
|
||||
|
||||
QByteArray fontName;
|
||||
};
|
||||
|
||||
struct QWSScreenTransformCommand : public QWSCommand
|
||||
{
|
||||
QWSScreenTransformCommand() :
|
||||
QWSCommand(QWSCommand::ScreenTransform,
|
||||
sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
|
||||
|
||||
void setTransformation(int screen, int transformation)
|
||||
{
|
||||
simpleData.screen = screen;
|
||||
simpleData.transformation = transformation;
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int screen;
|
||||
int transformation;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWSCOMMAND_QWS_P_H
|
@ -1,654 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcursor.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qscreen_qws.h"
|
||||
#include "qapplication.h"
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qwindowsystem_p.h"
|
||||
#include "qwscursor_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
static QWSCursor *systemCursorTable[Qt::LastCursor+1];
|
||||
static bool systemCursorTableInit = false;
|
||||
|
||||
// 16 x 16
|
||||
static const uchar cur_arrow_bits[] = {
|
||||
0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
|
||||
0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
|
||||
0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
|
||||
static const uchar mcur_arrow_bits[] = {
|
||||
0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
|
||||
0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
|
||||
0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
|
||||
|
||||
static const unsigned char cur_up_arrow_bits[] = {
|
||||
0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
|
||||
0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
|
||||
0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
|
||||
static const unsigned char mcur_up_arrow_bits[] = {
|
||||
0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
|
||||
0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
|
||||
|
||||
static const unsigned char cur_cross_bits[] = {
|
||||
0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
|
||||
0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
|
||||
0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
|
||||
static const unsigned char mcur_cross_bits[] = {
|
||||
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
|
||||
|
||||
static const uchar cur_ibeam_bits[] = {
|
||||
0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
|
||||
0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
|
||||
0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar mcur_ibeam_bits[] = {
|
||||
0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
|
||||
0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
|
||||
|
||||
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 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 };
|
||||
|
||||
// 20 x 20
|
||||
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};
|
||||
|
||||
// 32 x 32
|
||||
static const uchar wait_data_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
|
||||
0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
|
||||
0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
|
||||
0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
|
||||
0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
|
||||
0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 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 wait_mask_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
|
||||
0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
|
||||
0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
|
||||
0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
|
||||
0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
|
||||
0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 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 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 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 phand_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
|
||||
0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
|
||||
0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
|
||||
0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
|
||||
0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 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, 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[] = {
|
||||
0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
|
||||
0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
|
||||
0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
|
||||
0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
|
||||
0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
|
||||
0x00, 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, 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 size_all_data_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, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
|
||||
0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 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, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const uchar size_all_mask_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, 0xc2, 0x21, 0x00,
|
||||
0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
|
||||
0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
|
||||
0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 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, 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};
|
||||
|
||||
// 16 x 16
|
||||
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,
|
||||
0xfe,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};
|
||||
|
||||
#endif
|
||||
|
||||
void QWSServerPrivate::initializeCursor()
|
||||
{
|
||||
Q_Q(QWSServer);
|
||||
// setup system cursors
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
// qt_screen->initCursor(sharedram + ramlen,true);
|
||||
|
||||
// default cursor
|
||||
cursor = 0;
|
||||
setCursor(QWSCursor::systemCursor(Qt::ArrowCursor));
|
||||
#endif
|
||||
q->sendMouseEvent(QPoint(swidth/2, sheight/2), 0);
|
||||
}
|
||||
|
||||
void QWSServerPrivate::setCursor(QWSCursor *curs)
|
||||
{
|
||||
#ifdef QT_NO_QWS_CURSOR
|
||||
Q_UNUSED(curs);
|
||||
#else
|
||||
if (cursor == curs)
|
||||
return;
|
||||
|
||||
cursor = curs;
|
||||
|
||||
if (!haveviscurs || !curs)
|
||||
curs = QWSCursor::systemCursor(Qt::BlankCursor);
|
||||
|
||||
if (qt_screencursor) {
|
||||
qt_screencursor->set(curs->image(),
|
||||
curs->hotSpot().x(),
|
||||
curs->hotSpot().y());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_QWS_CURSOR
|
||||
static void cleanupSystemCursorTable()
|
||||
{
|
||||
for (int i = 0; i <= Qt::LastCursor; i++)
|
||||
if (systemCursorTable[i]) {
|
||||
delete systemCursorTable[i];
|
||||
systemCursorTable[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void QWSCursor::createSystemCursor(int id)
|
||||
{
|
||||
#ifdef QT_NO_QWS_CURSOR
|
||||
Q_UNUSED(id);
|
||||
#else
|
||||
if (!systemCursorTableInit) {
|
||||
for (int i = 0; i <= Qt::LastCursor; i++)
|
||||
systemCursorTable[i] = 0;
|
||||
qAddPostRoutine(cleanupSystemCursorTable);
|
||||
systemCursorTableInit = true;
|
||||
}
|
||||
switch (id) {
|
||||
// 16x16 cursors
|
||||
case Qt::ArrowCursor:
|
||||
systemCursorTable[Qt::ArrowCursor] =
|
||||
new QWSCursor(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
|
||||
break;
|
||||
|
||||
case Qt::UpArrowCursor:
|
||||
systemCursorTable[Qt::UpArrowCursor] =
|
||||
new QWSCursor(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
|
||||
break;
|
||||
|
||||
case Qt::CrossCursor:
|
||||
systemCursorTable[Qt::CrossCursor] =
|
||||
new QWSCursor(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::IBeamCursor:
|
||||
systemCursorTable[Qt::IBeamCursor] =
|
||||
new QWSCursor(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::SizeVerCursor:
|
||||
systemCursorTable[Qt::SizeVerCursor] =
|
||||
new QWSCursor(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::SizeHorCursor:
|
||||
systemCursorTable[Qt::SizeHorCursor] =
|
||||
new QWSCursor(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::SizeBDiagCursor:
|
||||
systemCursorTable[Qt::SizeBDiagCursor] =
|
||||
new QWSCursor(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::SizeFDiagCursor:
|
||||
systemCursorTable[Qt::SizeFDiagCursor] =
|
||||
new QWSCursor(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
|
||||
break;
|
||||
|
||||
case Qt::BlankCursor:
|
||||
systemCursorTable[Qt::BlankCursor] =
|
||||
new QWSCursor(0, 0, 0, 0, 0, 0);
|
||||
break;
|
||||
|
||||
// 20x20 cursors
|
||||
case Qt::ForbiddenCursor:
|
||||
systemCursorTable[Qt::ForbiddenCursor] =
|
||||
new QWSCursor(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
|
||||
break;
|
||||
|
||||
// 32x32 cursors
|
||||
case Qt::WaitCursor:
|
||||
systemCursorTable[Qt::WaitCursor] =
|
||||
new QWSCursor(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
|
||||
break;
|
||||
|
||||
case Qt::SplitVCursor:
|
||||
systemCursorTable[Qt::SplitVCursor] =
|
||||
new QWSCursor(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
|
||||
break;
|
||||
|
||||
case Qt::SplitHCursor:
|
||||
systemCursorTable[Qt::SplitHCursor] =
|
||||
new QWSCursor(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
|
||||
break;
|
||||
|
||||
case Qt::SizeAllCursor:
|
||||
systemCursorTable[Qt::SizeAllCursor] =
|
||||
new QWSCursor(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
|
||||
break;
|
||||
|
||||
case Qt::PointingHandCursor:
|
||||
systemCursorTable[Qt::PointingHandCursor] =
|
||||
new QWSCursor(phand_bits, phandm_bits, 32, 32, 0, 0);
|
||||
break;
|
||||
|
||||
case Qt::WhatsThisCursor:
|
||||
systemCursorTable[Qt::WhatsThisCursor] =
|
||||
new QWSCursor(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
|
||||
break;
|
||||
case Qt::BusyCursor:
|
||||
systemCursorTable[Qt::BusyCursor] =
|
||||
new QWSCursor(busy_bits, busym_bits, 32, 32, 0, 0);
|
||||
break;
|
||||
|
||||
case Qt::OpenHandCursor:
|
||||
systemCursorTable[Qt::OpenHandCursor] =
|
||||
new QWSCursor(openhand_bits, openhandm_bits, 16, 16, 8, 8);
|
||||
break;
|
||||
case Qt::ClosedHandCursor:
|
||||
systemCursorTable[Qt::ClosedHandCursor] =
|
||||
new QWSCursor(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
|
||||
break;
|
||||
default:
|
||||
qWarning("Unknown system cursor %d", id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QWSCursor *QWSCursor::systemCursor(int id)
|
||||
{
|
||||
QWSCursor *cursor = 0;
|
||||
#ifdef QT_NO_QWS_CURSOR
|
||||
Q_UNUSED(id);
|
||||
#else
|
||||
if (id >= 0 && id <= Qt::LastCursor) {
|
||||
if (!systemCursorTable[id])
|
||||
createSystemCursor(id);
|
||||
cursor = systemCursorTable[id];
|
||||
}
|
||||
|
||||
if (cursor == 0) {
|
||||
if (!systemCursorTable[Qt::ArrowCursor])
|
||||
createSystemCursor(Qt::ArrowCursor);
|
||||
cursor = systemCursorTable[Qt::ArrowCursor];
|
||||
}
|
||||
#endif
|
||||
return cursor;
|
||||
}
|
||||
|
||||
void QWSCursor::set(const uchar *data, const uchar *mask,
|
||||
int width, int height, int hx, int hy)
|
||||
{
|
||||
#ifdef QT_NO_QWS_CURSOR
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(mask);
|
||||
Q_UNUSED(width);
|
||||
Q_UNUSED(height);
|
||||
Q_UNUSED(hx);
|
||||
Q_UNUSED(hy);
|
||||
#else
|
||||
hot.setX(hx);
|
||||
hot.setY(hy);
|
||||
|
||||
cursor = QImage(width,height, QImage::Format_Indexed8);
|
||||
|
||||
if (!width || !height || !data || !mask || cursor.isNull())
|
||||
return;
|
||||
|
||||
cursor.setColorCount(3);
|
||||
cursor.setColor(0, 0xff000000);
|
||||
cursor.setColor(1, 0xffffffff);
|
||||
cursor.setColor(2, 0x00000000);
|
||||
|
||||
int bytesPerLine = (width + 7) / 8;
|
||||
int p = 0;
|
||||
int d, m;
|
||||
|
||||
int x = -1, w = 0;
|
||||
|
||||
uchar *cursor_data = cursor.bits();
|
||||
int bpl = cursor.bytesPerLine();
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
for (int j = 0; j < bytesPerLine; j++, data++, mask++)
|
||||
{
|
||||
for (int b = 0; b < 8 && j*8+b < width; b++)
|
||||
{
|
||||
d = *data & (1 << b);
|
||||
m = *mask & (1 << b);
|
||||
if (d && m) p = 0;
|
||||
else if (!d && m) p = 1;
|
||||
else p = 2;
|
||||
cursor_data[j*8+b] = p;
|
||||
|
||||
// calc region
|
||||
if (x < 0 && m)
|
||||
x = j*8+b;
|
||||
else if (x >= 0 && !m) {
|
||||
x = -1;
|
||||
w = 0;
|
||||
}
|
||||
if (m)
|
||||
w++;
|
||||
}
|
||||
}
|
||||
if (x >= 0) {
|
||||
x = -1;
|
||||
w = 0;
|
||||
}
|
||||
cursor_data += bpl;
|
||||
}
|
||||
|
||||
if (qt_screencursor && qt_screencursor->supportsAlphaCursor())
|
||||
createDropShadow(5, 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
// now we're really silly
|
||||
void QWSCursor::createDropShadow(int dropx, int dropy)
|
||||
{
|
||||
//####
|
||||
#if 1 || defined(QT_NO_QWS_CURSOR) || defined(QT_NO_QWS_ALHPA_CURSOR)
|
||||
Q_UNUSED(dropx);
|
||||
Q_UNUSED(dropy);
|
||||
#else
|
||||
if (cursor.width() + dropx > 64 || cursor.height() + dropy > 64)
|
||||
return;
|
||||
|
||||
if (!cursor.hasAlphaBuffer()) {
|
||||
cursor.setAlphaBuffer(true);
|
||||
|
||||
const int nblur=4;
|
||||
const int darkness=140;
|
||||
|
||||
QImage drop(cursor.width()+dropx+nblur, cursor.height()+dropy+nblur, 8, 18);
|
||||
drop.setColor(0, 0xff000000); // bg (black)
|
||||
drop.setColor(1, 0xffffffff); // fg (white)
|
||||
for (int i=0; i<16; i++) {
|
||||
drop.setColor(2+i, (darkness*i/16)<<24);
|
||||
}
|
||||
drop.fill(2); // all trans
|
||||
QImage drop2 = drop.copy();
|
||||
|
||||
int cp;
|
||||
|
||||
// made solid shadow
|
||||
for (int row = 0; row < cursor.height(); row++) {
|
||||
for (int col = 0; col < cursor.width(); col++) {
|
||||
cp = cursor.pixelIndex(col, row);
|
||||
if (cp != 2)
|
||||
drop.setPixel(col+dropx, row+dropy, 17);
|
||||
}
|
||||
}
|
||||
|
||||
// blur shadow
|
||||
for (int blur=0; blur<nblur; blur++) {
|
||||
QImage& to((blur&1)?drop:drop2);
|
||||
QImage& from((blur&1)?drop2:drop);
|
||||
for (int row = 1; row < drop.height()-1; row++) {
|
||||
for (int col = 1; col < drop.width()-1; col++) {
|
||||
int t=0;
|
||||
for (int dx=-1; dx<=1; dx++) {
|
||||
for (int dy=-1; dy<=1; dy++) {
|
||||
t += from.pixelIndex(col+dx,row+dy)-2;
|
||||
}
|
||||
}
|
||||
to.setPixel(col,row,2+t/9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copy cursor
|
||||
for (int row = 0; row < cursor.height(); row++) {
|
||||
for (int col = 0; col < cursor.width(); col++) {
|
||||
cp = cursor.pixelIndex(col, row);
|
||||
if (cp != 2)
|
||||
drop.setPixel(col, row, cp);
|
||||
}
|
||||
}
|
||||
|
||||
cursor = drop;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,83 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSCURSOR_QWS_H
|
||||
#define QWSCURSOR_QWS_H
|
||||
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qregion.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QWSCursor
|
||||
{
|
||||
public:
|
||||
QWSCursor() {}
|
||||
QWSCursor(const uchar *data, const uchar *mask, int width, int height,
|
||||
int hotX, int hotY)
|
||||
{ set(data, mask, width, height, hotX, hotY); }
|
||||
|
||||
void set(const uchar *data, const uchar *mask,
|
||||
int width, int height, int hotX, int hotY);
|
||||
|
||||
QPoint hotSpot() const { return hot; }
|
||||
QImage &image() { return cursor; }
|
||||
|
||||
static QWSCursor *systemCursor(int id);
|
||||
|
||||
private:
|
||||
static void createSystemCursor(int id);
|
||||
void createDropShadow(int dropx, int dropy);
|
||||
|
||||
private:
|
||||
QPoint hot;
|
||||
QImage cursor;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSCURSOR_QWS_H
|
@ -1,185 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSDISPLAY_QWS_H
|
||||
#define QWSDISPLAY_QWS_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtGui/qregion.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QWSEvent;
|
||||
class QWSMouseEvent;
|
||||
class QWSQCopMessageEvent;
|
||||
class QVariant;
|
||||
class QLock;
|
||||
|
||||
class QWSWindowInfo
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
int winid;
|
||||
unsigned int clientid;
|
||||
QString name;
|
||||
|
||||
};
|
||||
|
||||
#define QT_QWS_PROPERTY_CONVERTSELECTION 999
|
||||
#define QT_QWS_PROPERTY_WINDOWNAME 998
|
||||
#define QT_QWS_PROPERTY_MARKEDTEXT 997
|
||||
|
||||
class QWSDisplay;
|
||||
extern Q_GUI_EXPORT QWSDisplay *qt_fbdpy;
|
||||
|
||||
class Q_GUI_EXPORT QWSDisplay
|
||||
{
|
||||
public:
|
||||
QWSDisplay();
|
||||
~QWSDisplay();
|
||||
|
||||
static QWSDisplay* instance() { return qt_fbdpy; }
|
||||
|
||||
bool eventPending() const;
|
||||
QWSEvent *getEvent();
|
||||
// QWSRegionManager *regionManager() const;
|
||||
|
||||
uchar* frameBuffer() const;
|
||||
int width() const;
|
||||
int height() const;
|
||||
int depth() const;
|
||||
int pixmapDepth() const;
|
||||
bool supportsDepth(int) const;
|
||||
|
||||
uchar *sharedRam() const;
|
||||
int sharedRamSize() const;
|
||||
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
void addProperty(int winId, int property);
|
||||
void setProperty(int winId, int property, int mode, const QByteArray &data);
|
||||
void setProperty(int winId, int property, int mode, const char * data);
|
||||
void removeProperty(int winId, int property);
|
||||
bool getProperty(int winId, int property, char *&data, int &len);
|
||||
#endif // QT_NO_QWS_PROPERTIES
|
||||
|
||||
QList<QWSWindowInfo> windowList();
|
||||
int windowAt(const QPoint &);
|
||||
|
||||
void setIdentity(const QString &appName);
|
||||
void nameRegion(int winId, const QString& n, const QString &c);
|
||||
void requestRegion(int winId, const QString &surfacekey,
|
||||
const QByteArray &surfaceData,
|
||||
const QRegion ®ion);
|
||||
void repaintRegion(int winId, int windowFlags, bool opaque, QRegion);
|
||||
void moveRegion(int winId, int dx, int dy);
|
||||
void destroyRegion(int winId);
|
||||
void requestFocus(int winId, bool get);
|
||||
void setAltitude(int winId, int altitude, bool fixed = false);
|
||||
void setOpacity(int winId, int opacity);
|
||||
int takeId();
|
||||
void setSelectionOwner(int winId, const QTime &time);
|
||||
void convertSelection(int winId, int selectionProperty, const QString &mimeTypes);
|
||||
void defineCursor(int id, const QBitmap &curs, const QBitmap &mask,
|
||||
int hotX, int hotY);
|
||||
void destroyCursor(int id);
|
||||
void selectCursor(QWidget *w, unsigned int id);
|
||||
void setCursorPosition(int x, int y);
|
||||
void grabMouse(QWidget *w, bool grab);
|
||||
void grabKeyboard(QWidget *w, bool grab);
|
||||
void playSoundFile(const QString&);
|
||||
void registerChannel(const QString &channel);
|
||||
void sendMessage(const QString &channel, const QString &msg,
|
||||
const QByteArray &data);
|
||||
void flushCommands();
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
void sendIMUpdate(int type, int winId, int widgetid);
|
||||
void resetIM();
|
||||
void sendIMResponse(int winId, int property, const QVariant &result);
|
||||
void sendIMMouseEvent(int index, bool isPress);
|
||||
#endif
|
||||
QWSQCopMessageEvent* waitForQCopResponse();
|
||||
void sendFontCommand(int type, const QByteArray &fontName);
|
||||
|
||||
void setWindowCaption(QWidget *w, const QString &);
|
||||
|
||||
// Lock display for access only by this process
|
||||
static bool initLock(const QString &filename, bool create = false);
|
||||
static bool grabbed();
|
||||
static void grab();
|
||||
static void grab(bool write);
|
||||
static void ungrab();
|
||||
|
||||
static void setTransformation(int transformation, int screenNo = -1);
|
||||
static void setRawMouseEventFilter(void (*filter)(QWSMouseEvent *));
|
||||
|
||||
private:
|
||||
friend int qt_fork_qapplication();
|
||||
friend void qt_app_reinit( const QString& newAppName );
|
||||
friend class QApplication;
|
||||
friend class QCopChannel;
|
||||
friend class QWSEmbedWidget;
|
||||
friend class QWSEmbedWidgetPrivate;
|
||||
class Data;
|
||||
friend class Data;
|
||||
Data *d;
|
||||
|
||||
friend class QWSMemorySurface;
|
||||
friend class QWSOnScreenSurface;
|
||||
friend class QWSDirectPainterSurface;
|
||||
int getPropertyLen;
|
||||
char *getPropertyData;
|
||||
static QLock *lock;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSDISPLAY_QWS_H
|
@ -1,161 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSDISPLAY_QWS_P_H
|
||||
#define QWSDISPLAY_QWS_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 "qwsdisplay_qws.h"
|
||||
#include "qwssocket_qws.h"
|
||||
#include "qwsevent_qws.h"
|
||||
#include <private/qwssharedmemory_p.h>
|
||||
#include "qwscommand_qws_p.h"
|
||||
#include "qwslock_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWSDisplay::Data
|
||||
{
|
||||
public:
|
||||
Data(QObject* parent, bool singleProcess = false);
|
||||
~Data();
|
||||
|
||||
void flush();
|
||||
|
||||
bool queueNotEmpty();
|
||||
QWSEvent *dequeue();
|
||||
QWSEvent *peek();
|
||||
|
||||
bool directServerConnection();
|
||||
void fillQueue();
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
void connectToPipe();
|
||||
void waitForConnection();
|
||||
void waitForPropertyReply();
|
||||
void waitForRegionAck(int winId);
|
||||
void waitForRegionEvents(int winId, bool ungrabDisplay);
|
||||
bool hasPendingRegionEvents() const;
|
||||
#endif
|
||||
void waitForCreation();
|
||||
#ifndef QT_NO_COP
|
||||
void waitForQCopResponse();
|
||||
#endif
|
||||
void init();
|
||||
void reinit( const QString& newAppName );
|
||||
void create(int n = 1);
|
||||
|
||||
void flushCommands();
|
||||
void sendCommand(QWSCommand & cmd);
|
||||
void sendSynchronousCommand(QWSCommand & cmd);
|
||||
|
||||
QWSEvent *readMore();
|
||||
|
||||
int takeId();
|
||||
|
||||
void setMouseFilter(void (*filter)(QWSMouseEvent*));
|
||||
|
||||
//####public data members
|
||||
|
||||
// QWSRegionManager *rgnMan;
|
||||
uchar *sharedRam;
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
QWSSharedMemory shm;
|
||||
#endif
|
||||
int sharedRamSize;
|
||||
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
static QWSLock *clientLock;
|
||||
|
||||
static bool lockClient(QWSLock::LockType, int timeout = -1);
|
||||
static void unlockClient(QWSLock::LockType);
|
||||
static bool waitClient(QWSLock::LockType, int timeout = -1);
|
||||
static QWSLock* getClientLock();
|
||||
#endif // QT_NO_QWS_MULTIPROCESS
|
||||
|
||||
private:
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
QWSSocket *csocket;
|
||||
#endif
|
||||
QList<QWSEvent*> queue;
|
||||
|
||||
#if 0
|
||||
void debugQueue() {
|
||||
for (int i = 0; i < queue.size(); ++i) {
|
||||
QWSEvent *e = queue.at(i);
|
||||
qDebug( " ev %d type %d sl %d rl %d", i, e->type, e->simpleLen, e->rawLen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QWSConnectedEvent* connected_event;
|
||||
QWSMouseEvent* mouse_event;
|
||||
int region_events_count;
|
||||
int mouse_state;
|
||||
int mouse_winid;
|
||||
QPoint region_offset;
|
||||
int region_offset_window;
|
||||
#ifndef QT_NO_COP
|
||||
QWSQCopMessageEvent *qcop_response;
|
||||
#endif
|
||||
QWSEvent* current_event;
|
||||
QList<int> unused_identifiers;
|
||||
#ifdef QAPPLICATION_EXTRA_DEBUG
|
||||
int mouse_event_count;
|
||||
#endif
|
||||
void (*mouseFilter)(QWSMouseEvent *);
|
||||
|
||||
enum { VariableEvent=-1 };
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWSDISPLAY_QWS_P_H
|
@ -1,216 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwsevent_qws.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QWSEvent *QWSEvent::factory(int type)
|
||||
{
|
||||
QWSEvent *event = 0;
|
||||
switch (type) {
|
||||
case QWSEvent::Connected:
|
||||
event = new QWSConnectedEvent;
|
||||
break;
|
||||
case QWSEvent::MaxWindowRect:
|
||||
event = new QWSMaxWindowRectEvent;
|
||||
break;
|
||||
case QWSEvent::Mouse:
|
||||
event = new QWSMouseEvent;
|
||||
break;
|
||||
case QWSEvent::Focus:
|
||||
event = new QWSFocusEvent;
|
||||
break;
|
||||
case QWSEvent::Key:
|
||||
event = new QWSKeyEvent;
|
||||
break;
|
||||
case QWSEvent::Region:
|
||||
event = new QWSRegionEvent;
|
||||
break;
|
||||
case QWSEvent::Creation:
|
||||
event = new QWSCreationEvent;
|
||||
break;
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
case QWSEvent::PropertyNotify:
|
||||
event = new QWSPropertyNotifyEvent;
|
||||
break;
|
||||
case QWSEvent::PropertyReply:
|
||||
event = new QWSPropertyReplyEvent;
|
||||
break;
|
||||
#endif // QT_NO_QWS_PROPERTIES
|
||||
case QWSEvent::SelectionClear:
|
||||
event = new QWSSelectionClearEvent;
|
||||
break;
|
||||
case QWSEvent::SelectionRequest:
|
||||
event = new QWSSelectionRequestEvent;
|
||||
break;
|
||||
case QWSEvent::SelectionNotify:
|
||||
event = new QWSSelectionNotifyEvent;
|
||||
break;
|
||||
#ifndef QT_NO_COP
|
||||
case QWSEvent::QCopMessage:
|
||||
event = new QWSQCopMessageEvent;
|
||||
break;
|
||||
#endif
|
||||
case QWSEvent::WindowOperation:
|
||||
event = new QWSWindowOperationEvent;
|
||||
break;
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
case QWSEvent::IMEvent:
|
||||
event = new QWSIMEvent;
|
||||
break;
|
||||
case QWSEvent::IMQuery:
|
||||
event = new QWSIMQueryEvent;
|
||||
break;
|
||||
case QWSEvent::IMInit:
|
||||
event = new QWSIMInitEvent;
|
||||
break;
|
||||
#endif
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
case QWSEvent::Embed:
|
||||
event = new QWSEmbedEvent;
|
||||
break;
|
||||
#endif
|
||||
case QWSEvent::Font:
|
||||
event = new QWSFontEvent;
|
||||
break;
|
||||
case QWSEvent::ScreenTransformation:
|
||||
event = new QWSScreenTransformationEvent;
|
||||
break;
|
||||
default:
|
||||
qCritical("QWSEvent::factory() : Unknown event type %08x!", type);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWSEvent
|
||||
\ingroup qws
|
||||
|
||||
\brief The QWSEvent class encapsulates an event in Qt for Embedded Linux.
|
||||
|
||||
When running a \l{Qt for Embedded Linux} application, it either runs as a
|
||||
server or connects to an existing server. All system generated
|
||||
events are passed to the server application which then propagates
|
||||
the event to the appropriate client.
|
||||
|
||||
Whenever the server receives an event, it queries its stack of
|
||||
top-level windows to find the window containing the event's
|
||||
position. Each window can identify the client application that
|
||||
created it, and returns its ID to the server upon
|
||||
request. Finally, the server forwards the event, encapsulated by
|
||||
an instance of the QWSEvent class, to the appropriate client.
|
||||
|
||||
\image qt-embedded-client.png
|
||||
|
||||
The server communicates with the client applications over the UNIX
|
||||
domain socket. You can retrieve direct access to all the events a
|
||||
client receives from the server, by reimplementing QApplication's
|
||||
\l {QApplication::}{qwsEventFilter()} function.
|
||||
|
||||
QWSEvent provides the \l Type enum specifying the origin of the
|
||||
event. Internally, each type is represented by a QWSEvent
|
||||
subclass, e.g., \c QWSKeyEvent.
|
||||
|
||||
\sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QWSEvent::Type
|
||||
|
||||
This enum describes the origin of the event.
|
||||
|
||||
\value NoEvent No event has occurred.
|
||||
\value Connected An application has connected to the server.
|
||||
\value Mouse A mouse button is pressed or released, or the mouse cursor is moved.
|
||||
See also \l{Qt for Embedded Linux Pointer Handling}.
|
||||
\value Focus A window has lost or received focus.
|
||||
\value Key A key is pressed or released. See also \l{Qt for Embedded Linux Character Input}.
|
||||
\value Region A region has changed.
|
||||
\value Creation The server has created an ID, typically for a window.
|
||||
\value PropertyNotify A property has changed.
|
||||
\value PropertyReply The server is responding to a request for a property's value.
|
||||
\value SelectionClear A selection is deleted.
|
||||
\value SelectionRequest The server has queried for a selection.
|
||||
\value SelectionNotify A new selection has been created.
|
||||
\value MaxWindowRect The server has changed the maximum window for an application.
|
||||
\value QCopMessage A new Qt Cop message has appeared. See also QCopChannel
|
||||
\value WindowOperation A window operation, e.g. resizing, has occurred.
|
||||
\value IMEvent An input method has been used to enter text for languages with
|
||||
non-Latin alphabets. See also QWSInputMethod.
|
||||
\value IMQuery An input method query for a specified property has occurred.
|
||||
See also QWSInputMethod.
|
||||
\value NEvent The number of events has changed.
|
||||
\value Embed An event used internally to implement embedded windows. See also
|
||||
QWSEmbedWidget.
|
||||
\value ScreenTransformation An event used internally to notify the client processes
|
||||
that the screen has changed for example, rotation, etc.
|
||||
\omitvalue Font
|
||||
\omitvalue IMInit
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWSMouseEvent *QWSEvent::asMouse()
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QWSEvent::window()
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QWSEvent::window() const
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWSEvent *QWSEvent::factory(int type)
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWSEvent::QWSEvent( int t, int len, char * ptr)
|
||||
\internal
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,459 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSEVENT_QWS_H
|
||||
#define QWSEVENT_QWS_H
|
||||
|
||||
#include <QtGui/qwsutils_qws.h>
|
||||
#include <QtGui/qwsprotocolitem_qws.h>
|
||||
#include <QtCore/qrect.h>
|
||||
#include <QtGui/qregion.h>
|
||||
#include <QtCore/qvector.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
struct QWSMouseEvent;
|
||||
|
||||
struct QWSEvent : QWSProtocolItem {
|
||||
|
||||
QWSEvent(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}
|
||||
|
||||
|
||||
|
||||
enum Type {
|
||||
NoEvent,
|
||||
Connected,
|
||||
Mouse,
|
||||
Focus,
|
||||
Key,
|
||||
Region,
|
||||
Creation,
|
||||
PropertyNotify,
|
||||
PropertyReply,
|
||||
SelectionClear,
|
||||
SelectionRequest,
|
||||
SelectionNotify,
|
||||
MaxWindowRect,
|
||||
QCopMessage,
|
||||
WindowOperation,
|
||||
IMEvent,
|
||||
IMQuery,
|
||||
IMInit,
|
||||
Embed,
|
||||
Font,
|
||||
ScreenTransformation,
|
||||
NEvent
|
||||
};
|
||||
|
||||
QWSMouseEvent *asMouse()
|
||||
{ return type == Mouse ? reinterpret_cast<QWSMouseEvent*>(this) : 0; }
|
||||
int window() { return *(reinterpret_cast<int*>(simpleDataPtr)); }
|
||||
int window() const { return *(reinterpret_cast<int*>(simpleDataPtr)); }
|
||||
static QWSEvent *factory(int type);
|
||||
};
|
||||
|
||||
|
||||
//All events must start with windowID
|
||||
|
||||
struct QWSConnectedEvent : QWSEvent {
|
||||
QWSConnectedEvent()
|
||||
: QWSEvent(QWSEvent::Connected, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
display = reinterpret_cast<char*>(rawDataPtr);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int len;
|
||||
int clientId;
|
||||
int servershmid;
|
||||
} simpleData;
|
||||
|
||||
char *display;
|
||||
};
|
||||
|
||||
struct QWSMaxWindowRectEvent : QWSEvent {
|
||||
QWSMaxWindowRectEvent()
|
||||
: QWSEvent(MaxWindowRect, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
|
||||
struct SimpleData {
|
||||
int window;
|
||||
QRect rect;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSMouseEvent : QWSEvent {
|
||||
QWSMouseEvent()
|
||||
: QWSEvent(QWSEvent::Mouse, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int x_root, y_root, state, delta;
|
||||
int time; // milliseconds
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSFocusEvent : QWSEvent {
|
||||
QWSFocusEvent()
|
||||
: QWSEvent(QWSEvent::Focus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
|
||||
{ memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
|
||||
struct SimpleData {
|
||||
int window;
|
||||
uint get_focus:1;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSKeyEvent: QWSEvent {
|
||||
QWSKeyEvent()
|
||||
: QWSEvent(QWSEvent::Key, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int window;
|
||||
uint keycode;
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
ushort unicode;
|
||||
uint is_press:1;
|
||||
uint is_auto_repeat:1;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
|
||||
struct QWSCreationEvent : QWSEvent {
|
||||
QWSCreationEvent()
|
||||
: QWSEvent(QWSEvent::Creation, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int objectid;
|
||||
int count;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
struct QWSPropertyNotifyEvent : QWSEvent {
|
||||
QWSPropertyNotifyEvent()
|
||||
: QWSEvent(QWSEvent::PropertyNotify, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
enum State {
|
||||
PropertyNewValue,
|
||||
PropertyDeleted
|
||||
};
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int property;
|
||||
int state;
|
||||
} simpleData;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct QWSSelectionClearEvent : QWSEvent {
|
||||
QWSSelectionClearEvent()
|
||||
: QWSEvent(QWSEvent::SelectionClear, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int window;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSSelectionRequestEvent : QWSEvent {
|
||||
QWSSelectionRequestEvent()
|
||||
: QWSEvent(QWSEvent::SelectionRequest, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int requestor; // window which wants the selection
|
||||
int property; // property on requestor into which the selection should be stored, normally QWSProperty::PropSelection
|
||||
int mimeTypes; // Value is stored in the property mimeType on the requestor window. This value may contain
|
||||
// multiple mimeTypes separated by ;; where the order reflects the priority
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
struct QWSSelectionNotifyEvent : QWSEvent {
|
||||
QWSSelectionNotifyEvent()
|
||||
: QWSEvent(QWSEvent::SelectionNotify, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int requestor; // the window which wanted the selection and to which this event is sent
|
||||
int property; // property of requestor in which the data of the selection is stored
|
||||
int mimeType; // a property on the requestor in which the mime type in which the selection is, is stored
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
//complex events:
|
||||
|
||||
struct QWSRegionEvent : QWSEvent {
|
||||
QWSRegionEvent()
|
||||
: QWSEvent(QWSEvent::Region, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData))
|
||||
{ memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
rectangles = reinterpret_cast<QRect*>(rawDataPtr);
|
||||
}
|
||||
|
||||
void setData(int winId, const QRegion ®ion, uint type) {
|
||||
const QVector<QRect> rects = region.rects();
|
||||
setData(reinterpret_cast<const char*>(rects.constData()),
|
||||
rects.size() * sizeof(QRect));
|
||||
simpleData.window = winId;
|
||||
simpleData.nrectangles = rects.size();
|
||||
simpleData.type = type;
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
simpleData.id = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
enum Type {Allocation
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
, DirectPaint
|
||||
#endif
|
||||
};
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int nrectangles;
|
||||
#ifdef QT_QWS_CLIENTBLIT
|
||||
int id;
|
||||
#endif
|
||||
uint type:8;
|
||||
} simpleData;
|
||||
|
||||
QRect *rectangles;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_QWSEMBEDWIDGET
|
||||
struct QWSEmbedEvent : QWSEvent
|
||||
{
|
||||
QWSEmbedEvent() : QWSEvent(QWSEvent::Embed, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData))
|
||||
{}
|
||||
|
||||
enum Type { StartEmbed = 1, StopEmbed = 2, Region = 4 };
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
region.setRects(reinterpret_cast<const QRect *>(rawDataPtr),
|
||||
simpleData.nrectangles);
|
||||
}
|
||||
|
||||
void setData(int winId, Type type, const QRegion ® = QRegion()) {
|
||||
simpleData.window = winId;
|
||||
simpleData.nrectangles = reg.rects().size();
|
||||
simpleData.type = type;
|
||||
region = reg;
|
||||
const QVector<QRect> rects = reg.rects();
|
||||
QWSEvent::setData(reinterpret_cast<const char*>(rects.data()),
|
||||
rects.size() * sizeof(QRect));
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int nrectangles;
|
||||
Type type;
|
||||
} simpleData;
|
||||
|
||||
QRegion region;
|
||||
};
|
||||
#endif // QT_NO_QWSEMBEDWIDGET
|
||||
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
struct QWSPropertyReplyEvent : QWSEvent {
|
||||
QWSPropertyReplyEvent()
|
||||
: QWSEvent(QWSEvent::PropertyReply, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
data = reinterpret_cast<char*>(rawDataPtr);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int property;
|
||||
int len;
|
||||
} simpleData;
|
||||
char *data;
|
||||
};
|
||||
#endif //QT_NO_QWS_PROPERTIES
|
||||
|
||||
#ifndef QT_NO_COP
|
||||
struct QWSQCopMessageEvent : QWSEvent {
|
||||
QWSQCopMessageEvent()
|
||||
: QWSEvent(QWSEvent::QCopMessage, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData))
|
||||
{ memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
char* p = rawDataPtr;
|
||||
channel = QByteArray(p, simpleData.lchannel);
|
||||
p += simpleData.lchannel;
|
||||
message = QByteArray(p, simpleData.lmessage);
|
||||
p += simpleData.lmessage;
|
||||
data = QByteArray(p, simpleData.ldata);
|
||||
}
|
||||
|
||||
void setDataDirect(const char *d, int len) {
|
||||
QWSEvent::setData(d, len, false);
|
||||
deleteRaw = true;
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
bool is_response;
|
||||
int lchannel;
|
||||
int lmessage;
|
||||
int ldata;
|
||||
} simpleData;
|
||||
|
||||
QByteArray channel;
|
||||
QByteArray message;
|
||||
QByteArray data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct QWSWindowOperationEvent : QWSEvent {
|
||||
QWSWindowOperationEvent()
|
||||
: QWSEvent(WindowOperation, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
|
||||
|
||||
enum Operation { Show, Hide, ShowMaximized, ShowNormal, ShowMinimized, Close };
|
||||
struct SimpleData {
|
||||
int window;
|
||||
Operation op;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_QWS_INPUTMETHODS
|
||||
|
||||
|
||||
struct QWSIMEvent : QWSEvent {
|
||||
QWSIMEvent()
|
||||
: QWSEvent(IMEvent, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
|
||||
{ memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int replaceFrom;
|
||||
int replaceLength;
|
||||
} simpleData;
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
streamingData = QByteArray::fromRawData(rawDataPtr, len);
|
||||
}
|
||||
QByteArray streamingData;
|
||||
};
|
||||
|
||||
|
||||
struct QWSIMInitEvent : QWSEvent {
|
||||
QWSIMInitEvent()
|
||||
: QWSEvent(IMInit, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
|
||||
{ memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int existence;
|
||||
} simpleData;
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
streamingData = QByteArray::fromRawData(rawDataPtr, len);
|
||||
}
|
||||
QByteArray streamingData;
|
||||
};
|
||||
|
||||
|
||||
struct QWSIMQueryEvent : QWSEvent {
|
||||
QWSIMQueryEvent()
|
||||
: QWSEvent(QWSEvent::IMQuery, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int window;
|
||||
int property;
|
||||
} simpleData;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct QWSFontEvent : QWSEvent {
|
||||
QWSFontEvent()
|
||||
: QWSEvent(QWSEvent::Font, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
enum EventType {
|
||||
FontRemoved
|
||||
};
|
||||
|
||||
void setData(const char *d, int len, bool allocateMem = true) {
|
||||
QWSEvent::setData(d, len, allocateMem);
|
||||
fontName = QByteArray::fromRawData(rawDataPtr, len);
|
||||
}
|
||||
|
||||
struct SimpleData {
|
||||
uchar type;
|
||||
} simpleData;
|
||||
QByteArray fontName;
|
||||
};
|
||||
|
||||
struct QWSScreenTransformationEvent : QWSEvent {
|
||||
QWSScreenTransformationEvent()
|
||||
: QWSEvent(QWSEvent::ScreenTransformation, sizeof(simpleData),
|
||||
reinterpret_cast<char*>(&simpleData)) {}
|
||||
|
||||
struct SimpleData {
|
||||
int screen;
|
||||
int transformation;
|
||||
} simpleData;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSEVENT_QWS_H
|
@ -1,537 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwsmanager_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_MANAGER
|
||||
|
||||
#include "qdrawutil.h"
|
||||
#include "qapplication.h"
|
||||
#include "qstyle.h"
|
||||
#include "qwidget.h"
|
||||
#include "qmenu.h"
|
||||
#include "qpainter.h"
|
||||
#include "private/qpainter_p.h"
|
||||
#include "qregion.h"
|
||||
#include "qevent.h"
|
||||
#include "qcursor.h"
|
||||
#include "qwsdisplay_qws.h"
|
||||
#include "qdesktopwidget.h"
|
||||
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qbackingstore_p.h>
|
||||
#include <private/qwindowsurface_qws_p.h>
|
||||
#include "qdecorationfactory_qws.h"
|
||||
|
||||
#include "qlayout.h"
|
||||
|
||||
#include "qwsmanager_p.h"
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QWidget *QWSManagerPrivate::active = 0;
|
||||
QPoint QWSManagerPrivate::mousePos;
|
||||
|
||||
|
||||
QWSManagerPrivate::QWSManagerPrivate()
|
||||
: QObjectPrivate(), activeRegion(QDecoration::None), managed(0), popup(0),
|
||||
previousRegionType(0), previousRegionRepainted(false), entireDecorationNeedsRepaint(false)
|
||||
{
|
||||
cached_region.regionType = 0;
|
||||
}
|
||||
|
||||
QRegion &QWSManager::cachedRegion()
|
||||
{
|
||||
return d_func()->cached_region.region;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWSManager
|
||||
\ingroup qws
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
QWSManager::QWSManager(QWidget *w)
|
||||
: QObject(*new QWSManagerPrivate, (QObject*)0)
|
||||
{
|
||||
d_func()->managed = w;
|
||||
|
||||
}
|
||||
|
||||
QWSManager::~QWSManager()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
#ifndef QT_NO_MENU
|
||||
if (d->popup)
|
||||
delete d->popup;
|
||||
#endif
|
||||
if (d->managed == QWSManagerPrivate::active)
|
||||
QWSManagerPrivate::active = 0;
|
||||
}
|
||||
|
||||
QWidget *QWSManager::widget()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
return d->managed;
|
||||
}
|
||||
|
||||
QWidget *QWSManager::grabbedMouse()
|
||||
{
|
||||
return QWSManagerPrivate::active;
|
||||
}
|
||||
|
||||
QRegion QWSManager::region()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
return QApplication::qwsDecoration().region(d->managed, d->managed->geometry());
|
||||
}
|
||||
|
||||
bool QWSManager::event(QEvent *e)
|
||||
{
|
||||
if (QObject::event(e))
|
||||
return true;
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseMove:
|
||||
mouseMoveEvent((QMouseEvent*)e);
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonPress:
|
||||
mousePressEvent((QMouseEvent*)e);
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonRelease:
|
||||
mouseReleaseEvent((QMouseEvent*)e);
|
||||
break;
|
||||
|
||||
case QEvent::MouseButtonDblClick:
|
||||
mouseDoubleClickEvent((QMouseEvent*)e);
|
||||
break;
|
||||
|
||||
case QEvent::Paint:
|
||||
paintEvent((QPaintEvent*)e);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWSManager::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
d->mousePos = e->globalPos();
|
||||
d->activeRegion = QApplication::qwsDecoration().regionAt(d->managed, d->mousePos);
|
||||
if(d->cached_region.regionType)
|
||||
d->previousRegionRepainted |= repaintRegion(d->cached_region.regionType, QDecoration::Pressed);
|
||||
|
||||
if (d->activeRegion == QDecoration::Menu) {
|
||||
QPoint pos = (QApplication::layoutDirection() == Qt::LeftToRight
|
||||
? d->managed->geometry().topLeft()
|
||||
: d->managed->geometry().topRight());
|
||||
menu(pos);
|
||||
}
|
||||
if (d->activeRegion != QDecoration::None &&
|
||||
d->activeRegion != QDecoration::Menu) {
|
||||
d->active = d->managed;
|
||||
d->managed->grabMouse();
|
||||
}
|
||||
if (d->activeRegion != QDecoration::None &&
|
||||
d->activeRegion != QDecoration::Close &&
|
||||
d->activeRegion != QDecoration::Minimize &&
|
||||
d->activeRegion != QDecoration::Menu) {
|
||||
d->managed->raise();
|
||||
}
|
||||
|
||||
if (e->button() == Qt::RightButton) {
|
||||
menu(e->globalPos());
|
||||
}
|
||||
}
|
||||
|
||||
void QWSManager::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
d->managed->releaseMouse();
|
||||
if (d->cached_region.regionType && d->previousRegionRepainted && QApplication::mouseButtons() == 0) {
|
||||
bool doesHover = repaintRegion(d->cached_region.regionType, QDecoration::Hover);
|
||||
if (!doesHover) {
|
||||
repaintRegion(d->cached_region.regionType, QDecoration::Normal);
|
||||
d->previousRegionRepainted = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
//handleMove();
|
||||
int itm = QApplication::qwsDecoration().regionAt(d->managed, e->globalPos());
|
||||
int activatedItem = d->activeRegion;
|
||||
d->activeRegion = QDecoration::None;
|
||||
d->active = 0;
|
||||
if (activatedItem == itm)
|
||||
QApplication::qwsDecoration().regionClicked(d->managed, itm);
|
||||
} else if (d->activeRegion == QDecoration::None) {
|
||||
d->active = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QWSManager::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
if (e->button() == Qt::LeftButton)
|
||||
QApplication::qwsDecoration().regionDoubleClicked(d->managed,
|
||||
QApplication::qwsDecoration().regionAt(d->managed, e->globalPos()));
|
||||
}
|
||||
|
||||
static inline Qt::CursorShape regionToShape(int region)
|
||||
{
|
||||
if (region == QDecoration::None)
|
||||
return Qt::ArrowCursor;
|
||||
|
||||
static const struct {
|
||||
int region;
|
||||
Qt::CursorShape shape;
|
||||
} r2s[] = {
|
||||
{ QDecoration::TopLeft, Qt::SizeFDiagCursor },
|
||||
{ QDecoration::Top, Qt::SizeVerCursor},
|
||||
{ QDecoration::TopRight, Qt::SizeBDiagCursor},
|
||||
{ QDecoration::Left, Qt::SizeHorCursor},
|
||||
{ QDecoration::Right, Qt::SizeHorCursor},
|
||||
{ QDecoration::BottomLeft, Qt::SizeBDiagCursor},
|
||||
{ QDecoration::Bottom, Qt::SizeVerCursor},
|
||||
{ QDecoration::BottomRight, Qt::SizeFDiagCursor},
|
||||
{ QDecoration::None, Qt::ArrowCursor}
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
while (region != r2s[i].region && r2s[i].region)
|
||||
++i;
|
||||
return r2s[i].shape;
|
||||
}
|
||||
|
||||
void QWSManager::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
if (d->newCachedRegion(e->globalPos())) {
|
||||
if(d->previousRegionType && d->previousRegionRepainted)
|
||||
repaintRegion(d->previousRegionType, QDecoration::Normal);
|
||||
if(d->cached_region.regionType) {
|
||||
d->previousRegionRepainted = repaintRegion(d->cached_region.regionType, QDecoration::Hover);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
if (d->managed->minimumSize() != d->managed->maximumSize()) {
|
||||
QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay();
|
||||
qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt()));
|
||||
}
|
||||
#endif //QT_NO_CURSOR
|
||||
|
||||
if (d->activeRegion)
|
||||
handleMove(e->globalPos());
|
||||
}
|
||||
|
||||
void QWSManager::handleMove(QPoint g)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
|
||||
// don't allow dragging to where the user probably cannot click!
|
||||
QApplicationPrivate *ap = QApplicationPrivate::instance();
|
||||
const QRect maxWindowRect = ap->maxWindowRect(qt_screen);
|
||||
if (maxWindowRect.isValid()) {
|
||||
if (g.x() < maxWindowRect.x())
|
||||
g.setX(maxWindowRect.x());
|
||||
if (g.y() < maxWindowRect.y())
|
||||
g.setY(maxWindowRect.y());
|
||||
if (g.x() > maxWindowRect.right())
|
||||
g.setX(maxWindowRect.right());
|
||||
if (g.y() > maxWindowRect.bottom())
|
||||
g.setY(maxWindowRect.bottom());
|
||||
}
|
||||
|
||||
if (g == d->mousePos)
|
||||
return;
|
||||
|
||||
if ( d->managed->isMaximized() )
|
||||
return;
|
||||
|
||||
int x = d->managed->geometry().x();
|
||||
int y = d->managed->geometry().y();
|
||||
int w = d->managed->width();
|
||||
int h = d->managed->height();
|
||||
|
||||
QRect geom(d->managed->geometry());
|
||||
|
||||
QPoint delta = g - d->mousePos;
|
||||
d->mousePos = g;
|
||||
|
||||
if (d->activeRegion == QDecoration::Title) {
|
||||
geom = QRect(x + delta.x(), y + delta.y(), w, h);
|
||||
} else {
|
||||
bool keepTop = true;
|
||||
bool keepLeft = true;
|
||||
switch (d->activeRegion) {
|
||||
case QDecoration::Top:
|
||||
geom.setTop(geom.top() + delta.y());
|
||||
keepTop = false;
|
||||
break;
|
||||
case QDecoration::Bottom:
|
||||
geom.setBottom(geom.bottom() + delta.y());
|
||||
keepTop = true;
|
||||
break;
|
||||
case QDecoration::Left:
|
||||
geom.setLeft(geom.left() + delta.x());
|
||||
keepLeft = false;
|
||||
break;
|
||||
case QDecoration::Right:
|
||||
geom.setRight(geom.right() + delta.x());
|
||||
keepLeft = true;
|
||||
break;
|
||||
case QDecoration::TopRight:
|
||||
geom.setTopRight(geom.topRight() + delta);
|
||||
keepLeft = true;
|
||||
keepTop = false;
|
||||
break;
|
||||
case QDecoration::TopLeft:
|
||||
geom.setTopLeft(geom.topLeft() + delta);
|
||||
keepLeft = false;
|
||||
keepTop = false;
|
||||
break;
|
||||
case QDecoration::BottomLeft:
|
||||
geom.setBottomLeft(geom.bottomLeft() + delta);
|
||||
keepLeft = false;
|
||||
keepTop = true;
|
||||
break;
|
||||
case QDecoration::BottomRight:
|
||||
geom.setBottomRight(geom.bottomRight() + delta);
|
||||
keepLeft = true;
|
||||
keepTop = true;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
QSize newSize = QLayout::closestAcceptableSize(d->managed, geom.size());
|
||||
|
||||
int dx = newSize.width() - geom.width();
|
||||
int dy = newSize.height() - geom.height();
|
||||
|
||||
if (keepTop) {
|
||||
geom.setBottom(geom.bottom() + dy);
|
||||
d->mousePos.ry() += dy;
|
||||
} else {
|
||||
geom.setTop(geom.top() - dy);
|
||||
d->mousePos.ry() -= dy;
|
||||
}
|
||||
if (keepLeft) {
|
||||
geom.setRight(geom.right() + dx);
|
||||
d->mousePos.rx() += dx;
|
||||
} else {
|
||||
geom.setLeft(geom.left() - dx);
|
||||
d->mousePos.rx() -= dx;
|
||||
}
|
||||
}
|
||||
if (geom != d->managed->geometry()) {
|
||||
QApplication::sendPostedEvents();
|
||||
d->managed->setGeometry(geom);
|
||||
}
|
||||
}
|
||||
|
||||
void QWSManager::paintEvent(QPaintEvent *)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
d->dirtyRegion(QDecoration::All, QDecoration::Normal);
|
||||
}
|
||||
|
||||
void QWSManagerPrivate::dirtyRegion(int decorationRegion,
|
||||
QDecoration::DecorationState state,
|
||||
const QRegion &clip)
|
||||
{
|
||||
QTLWExtra *topextra = managed->d_func()->extra->topextra;
|
||||
QWidgetBackingStore *bs = topextra->backingStore.data();
|
||||
const bool pendingUpdateRequest = bs->isDirty();
|
||||
|
||||
if (decorationRegion == QDecoration::All) {
|
||||
if (clip.isEmpty())
|
||||
entireDecorationNeedsRepaint = true;
|
||||
dirtyRegions.clear();
|
||||
dirtyStates.clear();
|
||||
}
|
||||
int i = dirtyRegions.indexOf(decorationRegion);
|
||||
if (i >= 0) {
|
||||
dirtyRegions.removeAt(i);
|
||||
dirtyStates.removeAt(i);
|
||||
}
|
||||
|
||||
dirtyRegions.append(decorationRegion);
|
||||
dirtyStates.append(state);
|
||||
if (!entireDecorationNeedsRepaint)
|
||||
dirtyClip += clip;
|
||||
|
||||
if (!pendingUpdateRequest)
|
||||
QApplication::postEvent(managed, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
|
||||
}
|
||||
|
||||
void QWSManagerPrivate::clearDirtyRegions()
|
||||
{
|
||||
dirtyRegions.clear();
|
||||
dirtyStates.clear();
|
||||
dirtyClip = QRegion();
|
||||
entireDecorationNeedsRepaint = false;
|
||||
}
|
||||
|
||||
bool QWSManager::repaintRegion(int decorationRegion, QDecoration::DecorationState state)
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
|
||||
d->dirtyRegion(decorationRegion, state);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QWSManager::menu(const QPoint &pos)
|
||||
{
|
||||
#ifdef QT_NO_MENU
|
||||
Q_UNUSED(pos);
|
||||
#else
|
||||
Q_D(QWSManager);
|
||||
if (d->popup)
|
||||
delete d->popup;
|
||||
|
||||
// Basic window operation menu
|
||||
d->popup = new QMenu();
|
||||
QApplication::qwsDecoration().buildSysMenu(d->managed, d->popup);
|
||||
connect(d->popup, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*)));
|
||||
|
||||
d->popup->popup(pos);
|
||||
d->activeRegion = QDecoration::None;
|
||||
#endif // QT_NO_MENU
|
||||
}
|
||||
|
||||
void QWSManager::menuTriggered(QAction *action)
|
||||
{
|
||||
#ifdef QT_NO_MENU
|
||||
Q_UNUSED(action);
|
||||
#else
|
||||
Q_D(QWSManager);
|
||||
QApplication::qwsDecoration().menuTriggered(d->managed, action);
|
||||
d->popup->deleteLater();
|
||||
d->popup = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWSManager::startMove()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
d->mousePos = QCursor::pos();
|
||||
d->activeRegion = QDecoration::Title;
|
||||
d->active = d->managed;
|
||||
d->managed->grabMouse();
|
||||
}
|
||||
|
||||
void QWSManager::startResize()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
d->activeRegion = QDecoration::BottomRight;
|
||||
d->active = d->managed;
|
||||
d->managed->grabMouse();
|
||||
}
|
||||
|
||||
void QWSManager::maximize()
|
||||
{
|
||||
Q_D(QWSManager);
|
||||
// find out how much space the decoration needs
|
||||
const int screen = QApplication::desktop()->screenNumber(d->managed);
|
||||
const QRect desk = QApplication::desktop()->availableGeometry(screen);
|
||||
QRect dummy(0, 0, 1, 1);
|
||||
QRect nr;
|
||||
QRegion r = QApplication::qwsDecoration().region(d->managed, dummy);
|
||||
if (r.isEmpty()) {
|
||||
nr = desk;
|
||||
} else {
|
||||
r += dummy; // make sure we get the full window region in case of 0 width borders
|
||||
QRect rect = r.boundingRect();
|
||||
nr = QRect(desk.x()-rect.x(), desk.y()-rect.y(),
|
||||
desk.width() - (rect.width()==1 ? 0 : rect.width()-1), // ==1 -> dummy
|
||||
desk.height() - (rect.height()==1 ? 0 : rect.height()-1));
|
||||
}
|
||||
d->managed->setGeometry(nr);
|
||||
}
|
||||
|
||||
bool QWSManagerPrivate::newCachedRegion(const QPoint &pos)
|
||||
{
|
||||
// Check if anything has changed that would affect the region caching
|
||||
if (managed->windowFlags() == cached_region.windowFlags
|
||||
&& managed->geometry() == cached_region.windowGeometry
|
||||
&& cached_region.region.contains(pos))
|
||||
return false;
|
||||
|
||||
// Update the cached region
|
||||
int reg = QApplication::qwsDecoration().regionAt(managed, pos);
|
||||
if (QWidget::mouseGrabber())
|
||||
reg = QDecoration::None;
|
||||
|
||||
previousRegionType = cached_region.regionType;
|
||||
cached_region.regionType = reg;
|
||||
cached_region.region = QApplication::qwsDecoration().region(managed, managed->geometry(),
|
||||
reg);
|
||||
// Make room for borders around the widget, even if the decoration doesn't have a frame.
|
||||
if (reg && !(reg & int(QDecoration::Borders))) {
|
||||
cached_region.region -= QApplication::qwsDecoration().region(managed, managed->geometry(), QDecoration::Borders);
|
||||
}
|
||||
cached_region.windowFlags = managed->windowFlags();
|
||||
cached_region.windowGeometry = managed->geometry();
|
||||
// QRect rec = cached_region.region.boundingRect();
|
||||
// qDebug("Updated cached region: 0x%04x (%d, %d) (%d, %d, %d, %d)",
|
||||
// reg, pos.x(), pos.y(), rec.x(), rec.y(), rec.right(), rec.bottom());
|
||||
return true;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_QWS_MANAGER
|
@ -1,122 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSMANAGER_QWS_H
|
||||
#define QWSMANAGER_QWS_H
|
||||
|
||||
#include <QtGui/qpixmap.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qdecoration_qws.h>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
#ifndef QT_NO_QWS_MANAGER
|
||||
|
||||
class QAction;
|
||||
class QPixmap;
|
||||
class QWidget;
|
||||
class QPopupMenu;
|
||||
class QRegion;
|
||||
class QMouseEvent;
|
||||
class QWSManagerPrivate;
|
||||
|
||||
class Q_GUI_EXPORT QWSManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QWSManager)
|
||||
public:
|
||||
explicit QWSManager(QWidget *);
|
||||
~QWSManager();
|
||||
|
||||
static QDecoration *newDefaultDecoration();
|
||||
|
||||
QWidget *widget();
|
||||
static QWidget *grabbedMouse();
|
||||
void maximize();
|
||||
void startMove();
|
||||
void startResize();
|
||||
|
||||
QRegion region();
|
||||
QRegion &cachedRegion();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void menuTriggered(QAction *action);
|
||||
|
||||
protected:
|
||||
void handleMove(QPoint g);
|
||||
|
||||
virtual bool event(QEvent *e);
|
||||
virtual void mouseMoveEvent(QMouseEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *);
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
bool repaintRegion(int region, QDecoration::DecorationState state);
|
||||
|
||||
void menu(const QPoint &);
|
||||
|
||||
private:
|
||||
friend class QWidget;
|
||||
friend class QETWidget;
|
||||
friend class QWidgetPrivate;
|
||||
friend class QApplication;
|
||||
friend class QApplicationPrivate;
|
||||
friend class QWidgetBackingStore;
|
||||
friend class QWSWindowSurface;
|
||||
friend class QGLDrawable;
|
||||
};
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include <QtGui/qdecorationdefault_qws.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
#endif // QT_NO_QWS_MANAGER
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSMANAGER_QWS_H
|
@ -1,145 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwsproperty_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
#include "qwscommand_qws_p.h"
|
||||
#include "qwindowsystem_qws.h"
|
||||
#include "qhash.h"
|
||||
#include "qalgorithms.h"
|
||||
#include "qbytearray.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWSPropertyManager::Data {
|
||||
public:
|
||||
QByteArray find(int winId, int property)
|
||||
{
|
||||
return properties.value(winId).value(property);
|
||||
}
|
||||
|
||||
typedef QHash<int, QHash<int, QByteArray> > PropertyHash;
|
||||
PropertyHash properties;
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Class: QWSPropertyManager
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
QWSPropertyManager::QWSPropertyManager()
|
||||
{
|
||||
d = new Data;
|
||||
}
|
||||
|
||||
QWSPropertyManager::~QWSPropertyManager()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::setProperty(int winId, int property, int mode, const char *data, int len)
|
||||
{
|
||||
QHash<int, QByteArray> props = d->properties.value(winId);
|
||||
QHash<int, QByteArray>::iterator it = props.find(property);
|
||||
if (it == props.end())
|
||||
return false;
|
||||
|
||||
switch (mode) {
|
||||
case PropReplace:
|
||||
d->properties[winId][property] = QByteArray(data, len);
|
||||
break;
|
||||
case PropAppend:
|
||||
d->properties[winId][property].append(data);
|
||||
break;
|
||||
case PropPrepend:
|
||||
d->properties[winId][property].prepend(data);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::hasProperty(int winId, int property)
|
||||
{
|
||||
return d->properties.value(winId).contains(property);
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::removeProperty(int winId, int property)
|
||||
{
|
||||
QWSPropertyManager::Data::PropertyHash::iterator it = d->properties.find(winId);
|
||||
if (it == d->properties.end())
|
||||
return false;
|
||||
return d->properties[winId].remove( property );
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::addProperty(int winId, int property)
|
||||
{
|
||||
if( !d->properties[winId].contains(property) )
|
||||
d->properties[winId][property] = QByteArray(); // only add if it doesn't exist
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::getProperty(int winId, int property, const char *&data, int &len)
|
||||
{
|
||||
QHash<int, QByteArray> props = d->properties.value(winId);
|
||||
QHash<int, QByteArray>::iterator it = props.find(property);
|
||||
if (it == props.end()) {
|
||||
data = 0;
|
||||
len = -1;
|
||||
return false;
|
||||
}
|
||||
data = it.value().constData();
|
||||
len = it.value().length();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QWSPropertyManager::removeProperties(int winId)
|
||||
{
|
||||
return d->properties.remove(winId);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_QWS_PROPERTIES
|
@ -1,96 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSPROPERTY_QWS_H
|
||||
#define QWSPROPERTY_QWS_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Class: QWSPropertyManager
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef QT_NO_QWS_PROPERTIES
|
||||
|
||||
class QWSPropertyManager
|
||||
{
|
||||
public:
|
||||
enum Mode {
|
||||
PropReplace = 0,
|
||||
PropPrepend,
|
||||
PropAppend
|
||||
};
|
||||
|
||||
// pre-defined properties
|
||||
enum Atom {
|
||||
PropSelection = 0
|
||||
};
|
||||
|
||||
QWSPropertyManager();
|
||||
~QWSPropertyManager();
|
||||
|
||||
bool setProperty(int winId, int property, int mode, const char *data, int len);
|
||||
bool hasProperty(int winId, int property);
|
||||
bool removeProperty(int winId, int property);
|
||||
bool addProperty(int winId, int property);
|
||||
bool getProperty(int winId, int property, const char *&data, int &len);
|
||||
bool removeProperties(int winId);
|
||||
|
||||
private:
|
||||
class Data;
|
||||
Data* d;
|
||||
};
|
||||
|
||||
#endif // QT_NO_QWS_PROPERTIES
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSPROPERTY_QWS_H
|
@ -1,100 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWSPROTOCOLITEM_QWS_H
|
||||
#define QWSPROTOCOLITEM_QWS_H
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* QWSCommand base class - only use derived classes from that
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QIODevice;
|
||||
|
||||
struct QWSProtocolItem
|
||||
{
|
||||
// ctor - dtor
|
||||
QWSProtocolItem(int t, int len, char *ptr) : type(t),
|
||||
simpleLen(len), rawLen(-1), deleteRaw(false), simpleDataPtr(ptr),
|
||||
rawDataPtr(0), bytesRead(0) { }
|
||||
virtual ~QWSProtocolItem();
|
||||
|
||||
// data
|
||||
int type;
|
||||
int simpleLen;
|
||||
int rawLen;
|
||||
bool deleteRaw;
|
||||
|
||||
// functions
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
void write(QIODevice *s);
|
||||
bool read(QIODevice *s);
|
||||
#endif
|
||||
void copyFrom(const QWSProtocolItem *item);
|
||||
|
||||
virtual void setData(const char *data, int len, bool allocateMem = true);
|
||||
|
||||
char *simpleDataPtr;
|
||||
char *rawDataPtr;
|
||||
// temp variables
|
||||
int bytesRead;
|
||||
};
|
||||
|
||||
// This should probably be a method on QWSProtocolItem, but this way avoids
|
||||
// changing the API of this apparently public header
|
||||
// size = (int)type + (int)rawLenSize + simpleLen + rawLen
|
||||
#define QWS_PROTOCOL_ITEM_SIZE( item ) \
|
||||
(2 * sizeof(int)) + ((item).simpleDataPtr ? (item).simpleLen : 0) + ((item).rawDataPtr ? (item).rawLen : 0)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QWSPROTOCOLITEM_QWS_H
|
@ -1,280 +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$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qplatformdefs.h"
|
||||
#include "qwssocket_qws.h"
|
||||
|
||||
#ifndef QT_NO_QWS_MULTIPROCESS
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifdef __MIPSEL__
|
||||
# ifndef SOCK_DGRAM
|
||||
# define SOCK_DGRAM 1
|
||||
# endif
|
||||
# ifndef SOCK_STREAM
|
||||
# define SOCK_STREAM 2
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_SOLARIS) || defined (QT_LINUXBASE)
|
||||
// uff-da apparently Solaris doesn't have the SUN_LEN macro, here is
|
||||
// an implementation of it...
|
||||
# ifndef SUN_LEN
|
||||
# define SUN_LEN(su) \
|
||||
sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)
|
||||
# endif
|
||||
|
||||
// nor the POSIX names of UNIX domain sockets *sigh*
|
||||
# ifndef AF_LOCAL
|
||||
# define AF_LOCAL AF_UNIX
|
||||
# endif
|
||||
# ifndef PF_LOCAL
|
||||
# define PF_LOCAL PF_UNIX
|
||||
# endif
|
||||
#endif // Q_OS_SOLARIS || QT_LINUXBASE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* QWSSocket
|
||||
*
|
||||
**********************************************************************/
|
||||
QWSSocket::QWSSocket(QObject *parent)
|
||||
: QWS_SOCK_BASE(parent)
|
||||
{
|
||||
#ifndef QT_NO_SXE
|
||||
QObject::connect( this, SIGNAL(stateChanged(SocketState)),
|
||||
this, SLOT(forwardStateChange(SocketState)));
|
||||
#endif
|
||||
}
|
||||
|
||||
QWSSocket::~QWSSocket()
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SXE
|
||||
QString QWSSocket::errorString()
|
||||
{
|
||||
switch (QUnixSocket::error()) {
|
||||
case NoError:
|
||||
return QString();
|
||||
case InvalidPath:
|
||||
case NonexistentPath:
|
||||
return QLatin1String("Bad path"); // NO_TR
|
||||
default:
|
||||
return QLatin1String("Bad socket"); // NO TR
|
||||
}
|
||||
}
|
||||
|
||||
void QWSSocket::forwardStateChange(QUnixSocket::SocketState st )
|
||||
{
|
||||
switch ( st )
|
||||
{
|
||||
case ConnectedState:
|
||||
emit connected();
|
||||
break;
|
||||
case ClosingState:
|
||||
break;
|
||||
case UnconnectedState:
|
||||
emit disconnected();
|
||||
break;
|
||||
default:
|
||||
// nothing
|
||||
break;
|
||||
}
|
||||
if ( QUnixSocket::error() != NoError )
|
||||
emit error((QAbstractSocket::SocketError)0);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool QWSSocket::connectToLocalFile(const QString &file)
|
||||
{
|
||||
#ifndef QT_NO_SXE
|
||||
bool result = QUnixSocket::connect( file.toLocal8Bit() );
|
||||
if ( !result )
|
||||
{
|
||||
perror( "QWSSocketAuth::connectToLocalFile could not connect:" );
|
||||
emit error(QAbstractSocket::ConnectionRefusedError);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
// create socket
|
||||
int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
|
||||
// connect to socket
|
||||
struct sockaddr_un a;
|
||||
memset(&a, 0, sizeof(a));
|
||||
a.sun_family = PF_LOCAL;
|
||||
strncpy(a.sun_path, file.toLocal8Bit().constData(), sizeof(a.sun_path) - 1);
|
||||
int r = ::connect(s, (struct sockaddr*)&a, SUN_LEN(&a));
|
||||
if (r == 0) {
|
||||
setSocketDescriptor(s);
|
||||
} else {
|
||||
perror("QWSSocket::connectToLocalFile could not connect:");
|
||||
::close(s);
|
||||
emit error(ConnectionRefusedError);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* QWSServerSocket
|
||||
*
|
||||
**********************************************************************/
|
||||
QWSServerSocket::QWSServerSocket(const QString& file, QObject *parent)
|
||||
#ifndef QT_NO_SXE
|
||||
: QUnixSocketServer(parent)
|
||||
#else
|
||||
: QTcpServer(parent)
|
||||
#endif
|
||||
{
|
||||
init(file);
|
||||
}
|
||||
|
||||
void QWSServerSocket::init(const QString &file)
|
||||
{
|
||||
#ifndef QT_NO_SXE
|
||||
QByteArray fn = file.toLocal8Bit();
|
||||
bool result = QUnixSocketServer::listen( fn );
|
||||
if ( !result )
|
||||
{
|
||||
QUnixSocketServer::ServerError err = serverError();
|
||||
switch ( err )
|
||||
{
|
||||
case InvalidPath:
|
||||
qWarning("QWSServerSocket:: invalid path %s", qPrintable(file));
|
||||
break;
|
||||
case ResourceError:
|
||||
case BindError:
|
||||
case ListenError:
|
||||
qWarning("QWSServerSocket:: could not listen on path %s", qPrintable(file));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
int backlog = 16; //#####
|
||||
|
||||
// create socket
|
||||
int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
if (s == -1) {
|
||||
perror("QWSServerSocket::init");
|
||||
qWarning("QWSServerSocket: unable to create socket.");
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray fn = file.toLocal8Bit();
|
||||
unlink(fn.constData()); // doesn't have to succeed
|
||||
|
||||
// bind socket
|
||||
struct sockaddr_un a;
|
||||
memset(&a, 0, sizeof(a));
|
||||
a.sun_family = PF_LOCAL;
|
||||
strncpy(a.sun_path, fn.constData(), sizeof(a.sun_path) - 1);
|
||||
int r = ::bind(s, (struct sockaddr*)&a, SUN_LEN(&a));
|
||||
if (r < 0) {
|
||||
perror("QWSServerSocket::init");
|
||||
qWarning("QWSServerSocket: could not bind to file %s", fn.constData());
|
||||
::close(s);
|
||||
return;
|
||||
}
|
||||
|
||||
if (chmod(fn.constData(), 0600) < 0) {
|
||||
perror("QWSServerSocket::init");
|
||||
qWarning("Could not set permissions of %s", fn.constData());
|
||||
::close(s);
|
||||
return;
|
||||
}
|
||||
|
||||
// listen
|
||||
if (::listen(s, backlog) == 0) {
|
||||
if (!setSocketDescriptor(s))
|
||||
qWarning( "QWSServerSocket could not set descriptor %d : %s", s, errorString().toLatin1().constData());
|
||||
} else {
|
||||
perror("QWSServerSocket::init");
|
||||
qWarning("QWSServerSocket: could not listen to file %s", fn.constData());
|
||||
::close(s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QWSServerSocket::~QWSServerSocket()
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SXE
|
||||
|
||||
void QWSServerSocket::incomingConnection(int socketDescriptor)
|
||||
{
|
||||
inboundConnections.append( socketDescriptor );
|
||||
emit newConnection();
|
||||
}
|
||||
|
||||
|
||||
QWSSocket *QWSServerSocket::nextPendingConnection()
|
||||
{
|
||||
QMutexLocker locker( &ssmx );
|
||||
if ( inboundConnections.count() == 0 )
|
||||
return 0;
|
||||
QWSSocket *s = new QWSSocket();
|
||||
s->setSocketDescriptor( inboundConnections.takeFirst() );
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif // QT_NO_SXE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_QWS_MULTIPROCESS
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user