Changeset 561 for trunk/src/gui/kernel/qapplication_x11.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qapplication_x11.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 79 79 #include <private/qcolor_p.h> 80 80 #include <private/qcursor_p.h> 81 #include <private/qiconloader_p.h> 82 #include <qgtkstyle.h> 81 83 #include "qstyle.h" 82 84 #include "qmetaobject.h" … … 84 86 #include "qlibrary.h" 85 87 #include <private/qgraphicssystemfactory_p.h> 88 #include "qguiplatformplugin_p.h" 89 #include "qkde_p.h" 86 90 87 91 #if !defined (QT_NO_TABLET) … … 118 122 #define XK_MISCELLANY 119 123 #include <X11/keysymdef.h> 124 #if !defined(QT_NO_XINPUT) 120 125 #include <X11/extensions/XI.h> 126 #endif 121 127 122 128 #include <stdlib.h> … … 128 134 129 135 #include <private/qbackingstore_p.h> 136 137 #ifdef QT_RX71_MULTITOUCH 138 # include <qsocketnotifier.h> 139 # include <linux/input.h> 140 # include <errno.h> 141 #endif 142 143 #if _POSIX_VERSION+0 < 200112L && !defined(Q_OS_BSD4) 144 # define QT_NO_UNSETENV 145 #endif 130 146 131 147 QT_BEGIN_NAMESPACE … … 158 174 "_NET_WM_PING\0" 159 175 "_NET_WM_CONTEXT_HELP\0" 176 "_NET_WM_SYNC_REQUEST\0" 177 "_NET_WM_SYNC_REQUEST_COUNTER\0" 160 178 161 179 // ICCCM window state … … 174 192 "MULTIPLE\0" 175 193 "TIMESTAMP\0" 194 "SAVE_TARGETS\0" 176 195 "CLIP_TEMPORARY\0" 177 196 "_QT_SELECTION\0" 178 197 "_QT_CLIPBOARD_SENTINEL\0" 179 198 "_QT_SELECTION_SENTINEL\0" 199 "CLIPBOARD_MANAGER\0" 180 200 181 201 "RESOURCE_MANAGER\0" … … 295 315 "_XEMBED\0" 296 316 "_XEMBED_INFO\0" 317 318 "Wacom Stylus\0" 319 "Wacom Cursor\0" 320 "Wacom Eraser\0" 297 321 }; 298 322 … … 399 423 extern bool qt_is_gui_used; 400 424 401 /*! 425 /*! 402 426 \internal 403 427 Try to resolve a \a symbol from \a library with the version specified … … 505 529 { 506 530 public: 531 QWidgetPrivate* d_func() { return QWidget::d_func(); } 507 532 bool translateMouseEvent(const XEvent *); 508 533 void translatePaintEvent(const XEvent *); … … 639 664 640 665 default: 666 #if !defined(QT_NO_XINPUT) 641 667 if (err->request_code == X11->xinput_major 642 668 && err->error_code == (X11->xinput_errorbase + XI_BadDevice) … … 644 670 return 0; 645 671 } 672 #endif 646 673 break; 647 674 } … … 715 742 #endif 716 743 744 #ifndef QT_NO_XSYNC 745 struct qt_sync_request_event_data 746 { 747 WId window; 748 }; 749 750 #if defined(Q_C_CALLBACKS) 751 extern "C" { 752 #endif 753 754 static Bool qt_sync_request_scanner(Display*, XEvent *event, XPointer arg) 755 { 756 qt_sync_request_event_data *data = 757 reinterpret_cast<qt_sync_request_event_data*>(arg); 758 if (event->type == ClientMessage && 759 event->xany.window == data->window && 760 event->xclient.message_type == ATOM(WM_PROTOCOLS) && 761 (Atom)event->xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST)) { 762 QWidget *w = QWidget::find(event->xany.window); 763 if (QTLWExtra *tlw = ((QETWidget*)w)->d_func()->maybeTopData()) { 764 const ulong timestamp = (const ulong) event->xclient.data.l[1]; 765 if (timestamp > X11->time) 766 X11->time = timestamp; 767 if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) { 768 tlw->syncRequestTimestamp = timestamp; 769 tlw->newCounterValueLo = event->xclient.data.l[2]; 770 tlw->newCounterValueHi = event->xclient.data.l[3]; 771 } 772 } 773 return true; 774 } 775 return false; 776 } 777 778 #if defined(Q_C_CALLBACKS) 779 } 780 #endif 781 #endif // QT_NO_XSYNC 717 782 718 783 static void qt_x11_create_intern_atoms() … … 753 818 ATOM(_QT_SETTINGS_TIMESTAMP), ATOM(_QT_SETTINGS_TIMESTAMP), 8, 754 819 PropModeReplace, (unsigned char *)stamp.data(), stamp.size()); 755 }756 757 /*! \internal758 Gets the current KDE 3 or 4 home path759 */760 QString QApplicationPrivate::kdeHome()761 {762 static QString kdeHomePath;763 if (kdeHomePath.isEmpty()) {764 kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));765 if (kdeHomePath.isEmpty()) {766 int kdeSessionVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();767 QDir homeDir(QDir::homePath());768 QString kdeConfDir(QLatin1String("/.kde"));769 if (4 == kdeSessionVersion && homeDir.exists(QLatin1String(".kde4")))770 kdeConfDir = QLatin1String("/.kde4");771 kdeHomePath = QDir::homePath() + kdeConfDir;772 }773 }774 return kdeHomePath;775 820 } 776 821 … … 831 876 832 877 // ### Fix properly for 4.6 833 if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) { 878 bool usingGtkSettings = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"); 879 if (!usingGtkSettings) { 834 880 if (groupCount == QPalette::NColorGroups) 835 881 QApplicationPrivate::setSystemPalette(pal); 836 882 } 837 883 838 int kdeSessionVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();839 840 884 if (!appFont) { 841 QFont font(QApplication::font()); 842 QString fontDescription; 843 // Override Qt font if KDE4 settings can be used 844 if (4 == kdeSessionVersion) { 845 QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); 846 fontDescription = kdeSettings.value(QLatin1String("font")).toString(); 847 if (fontDescription.isEmpty()) { 848 // KDE stores fonts without quotes 849 fontDescription = kdeSettings.value(QLatin1String("font")).toStringList().join(QLatin1String(",")); 850 } 851 } 852 if (fontDescription.isEmpty()) 853 fontDescription = settings.value(QLatin1String("font")).toString(); 854 if (!fontDescription .isEmpty()) { 855 font.fromString(fontDescription ); 856 QApplicationPrivate::setSystemFont(font); 885 // ### Fix properly for 4.6 886 if (!usingGtkSettings) { 887 QFont font(QApplication::font()); 888 QString fontDescription; 889 // Override Qt font if KDE4 settings can be used 890 if (X11->desktopVersion == 4) { 891 QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); 892 fontDescription = kdeSettings.value(QLatin1String("font")).toString(); 893 if (fontDescription.isEmpty()) { 894 // KDE stores fonts without quotes 895 fontDescription = kdeSettings.value(QLatin1String("font")).toStringList().join(QLatin1String(",")); 896 } 897 } 898 if (fontDescription.isEmpty()) 899 fontDescription = settings.value(QLatin1String("font")).toString(); 900 if (!fontDescription .isEmpty()) { 901 font.fromString(fontDescription ); 902 QApplicationPrivate::setSystemFont(font); 903 } 857 904 } 858 905 } … … 872 919 // read new QStyle 873 920 QString stylename = settings.value(QLatin1String("style")).toString(); 874 if (stylename.isEmpty() && !QApplicationPrivate::styleOverride && X11->use_xrender) { 875 QStringList availableStyles = QStyleFactory::keys(); 876 // Override Qt style if KDE4 settings can be used 877 if (4 == kdeSessionVersion) { 878 QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); 879 QString kde4Style = kdeSettings.value(QLatin1String("widgetStyle"), 880 QLatin1String("Oxygen")).toString(); 881 foreach (const QString &style, availableStyles) { 882 if (style.toLower() == kde4Style.toLower()) 883 stylename = kde4Style; 884 } 885 // Set QGtkStyle for GNOME 886 } else if (X11->desktopEnvironment == DE_GNOME) { 887 QString gtkStyleKey = QString::fromLatin1("GTK+"); 888 if (availableStyles.contains(gtkStyleKey)) 889 stylename = gtkStyleKey; 890 } 921 922 if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) { 923 stylename = qt_guiPlatformPlugin()->styleName(); 891 924 } 892 925 893 926 static QString currentStyleName = stylename; 894 927 if (QCoreApplication::startingUp()) { 895 if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride)896 QApplicationPrivate::styleOverride = new QString(stylename);928 if (!stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull()) 929 QApplicationPrivate::styleOverride = stylename; 897 930 } else { 898 931 if (currentStyleName != stylename) { … … 1044 1077 } 1045 1078 1046 // Reads a KDE color setting1047 static QColor kdeColor(const QString &key)1048 {1049 QSettings kdeSettings(QApplicationPrivate::kdeHome() +1050 QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);1051 QVariant variant = kdeSettings.value(key);1052 if (variant.isValid()) {1053 QStringList values = variant.toStringList();1054 if (values.size() == 3) {1055 int r = values[0].toInt();1056 int g = values[1].toInt();1057 int b = values[2].toInt();1058 return QColor(r, g, b);1059 }1060 }1061 return QColor();1062 }1063 1064 1079 // set font, foreground and background from x11 resources. The 1065 1080 // arguments may override the resource settings. … … 1082 1097 // first, read from settings 1083 1098 QApplicationPrivate::x11_apply_settings(); 1084 1085 1099 // the call to QApplication::style() below creates the system 1086 1100 // palette, which breaks the logic after the RESOURCE_MANAGER … … 1228 1242 QApplicationPrivate::setSystemFont(fnt); 1229 1243 } 1244 // QGtkStyle sets it's own system palette 1245 bool gtkStyle = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"); 1230 1246 bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE); 1231 1232 if (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty())) {// set app colors 1247 if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors 1233 1248 bool allowX11ColorNames = QColor::allowX11ColorNames(); 1234 1249 QColor::setAllowX11ColorNames(true); … … 1266 1281 } 1267 1282 1268 if (kdeColors) {1269 // Setup KDE palette1270 QColor color;1271 color = kdeColor(QLatin1String("buttonBackground"));1272 if (!color.isValid())1273 color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"));1274 if (color.isValid())1275 btn = color;1276 1277 color = kdeColor(QLatin1String("background"));1278 if (!color.isValid())1279 color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"));1280 if (color.isValid())1281 bg = color;1282 1283 color = kdeColor(QLatin1String("foreground"));1284 if (!color.isValid())1285 color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"));1286 if (color.isValid()) {1287 fg = color;1288 }1289 1290 color = kdeColor(QLatin1String("windowForeground"));1291 if (!color.isValid())1292 color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"));1293 if (color.isValid())1294 wfg = color;1295 1296 color = kdeColor(QLatin1String("windowBackground"));1297 if (!color.isValid())1298 color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"));1299 if (color.isValid())1300 base = color;1301 }1302 1303 1283 QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg); 1304 1284 QColor disabled((fg.red() + btn.red()) / 2, … … 1312 1292 highlight = QColor(selectBackground); 1313 1293 highlightText = QColor(selectForeground); 1314 }1315 // Use KDE3 or KDE4 color settings if present1316 if (kdeColors) {1317 QColor color = kdeColor(QLatin1String("selectBackground"));1318 if (!color.isValid())1319 color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"));1320 if (color.isValid())1321 highlight = color;1322 1323 color = kdeColor(QLatin1String("selectForeground"));1324 if (!color.isValid())1325 color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"));1326 if (color.isValid())1327 highlightText = color;1328 1329 color = kdeColor(QLatin1String("alternateBackground"));1330 if (!color.isValid())1331 color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"));1332 if (color.isValid())1333 pal.setColor(QPalette::AlternateBase, color);1334 else1335 pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110));1336 1337 color = kdeColor(QLatin1String("buttonForeground"));1338 if (!color.isValid())1339 color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"));1340 if (color.isValid())1341 pal.setColor(QPalette::ButtonText, color);1342 1294 } 1343 1295 … … 1363 1315 } 1364 1316 1365 // QGtkStyle sets it's own system palette 1366 if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) { 1367 QApplicationPrivate::setSystemPalette(pal); 1368 } 1317 pal = qt_guiPlatformPlugin()->palette().resolve(pal); 1318 QApplicationPrivate::setSystemPalette(pal); 1369 1319 QColor::setAllowX11ColorNames(allowX11ColorNames); 1370 1320 } … … 1386 1336 effects.contains(QLatin1String("animatetoolbox"))); 1387 1337 } 1338 1339 QIconLoader::instance()->updateSystemTheme(); 1388 1340 } 1389 1341 … … 1580 1532 static PtrWacomConfigCloseDevice ptrWacomConfigCloseDevice = 0; 1581 1533 static PtrWacomConfigTerm ptrWacomConfigTerm = 0; 1534 Q_GLOBAL_STATIC(QByteArray, wacomDeviceName) 1582 1535 #endif 1583 1536 … … 1673 1626 // MIT-SHM 1674 1627 X11->use_mitshm = false; 1628 X11->use_mitshm_pixmaps = false; 1675 1629 X11->mitshm_major = 0; 1676 1630 … … 1720 1674 #endif 1721 1675 1722 X11->startupId = X11->originalStartupId =0;1676 X11->startupId = 0; 1723 1677 1724 1678 int argc = priv->argc; … … 1902 1856 screen->ref = 1; // ensures it doesn't get deleted 1903 1857 screen->screen = s; 1904 screen->dpiX = (DisplayWidth(X11->display, s) * 254 + DisplayWidthMM(X11->display, s)*5) 1905 / (DisplayWidthMM(X11->display, s)*10); 1906 screen->dpiY = (DisplayHeight(X11->display, s) * 254 + DisplayHeightMM(X11->display, s)*5) 1907 / (DisplayHeightMM(X11->display, s)*10); 1858 1859 int widthMM = DisplayWidthMM(X11->display, s); 1860 if (widthMM != 0) { 1861 screen->dpiX = (DisplayWidth(X11->display, s) * 254 + widthMM * 5) / (widthMM * 10); 1862 } else { 1863 screen->dpiX = 72; 1864 } 1865 1866 int heightMM = DisplayHeightMM(X11->display, s); 1867 if (heightMM != 0) { 1868 screen->dpiY = (DisplayHeight(X11->display, s) * 254 + heightMM * 5) / (heightMM * 10); 1869 } else { 1870 screen->dpiY = 72; 1871 } 1908 1872 1909 1873 X11->argbVisuals[s] = 0; … … 1949 1913 QString displayName = QLatin1String(XDisplayName(NULL)); 1950 1914 1951 // apparently MITSHM only works for local displays, so do a quick check here 1952 // to determine whether the display is local or not (not 100 % accurate) 1915 // MITSHM only works for local displays, so do a quick check here 1916 // to determine whether the display is local or not (not 100 % accurate). 1917 // BGR server layouts are not supported either, since it requires the raster 1918 // engine to work on a QImage with BGR layout. 1953 1919 bool local = displayName.isEmpty() || displayName.lastIndexOf(QLatin1Char(':')) == 0; 1954 if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0)) 1955 X11->use_mitshm = mitshm_pixmaps; 1920 if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0)) { 1921 Visual *defaultVisual = DefaultVisual(X11->display, DefaultScreen(X11->display)); 1922 X11->use_mitshm = ((defaultVisual->red_mask == 0xff0000 1923 || defaultVisual->red_mask == 0xf800) 1924 && (defaultVisual->green_mask == 0xff00 1925 || defaultVisual->green_mask == 0x7e0) 1926 && (defaultVisual->blue_mask == 0xff 1927 || defaultVisual->blue_mask == 0x1f)); 1928 X11->use_mitshm_pixmaps = X11->use_mitshm && mitshm_pixmaps; 1929 } 1956 1930 } 1957 1931 #endif // QT_NO_MITSHM … … 2052 2026 } 2053 2027 } 2054 if (X11->use_xfixes && X11->ptrXFixesSelectSelectionInput) {2055 const unsigned long eventMask =2056 XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask;2057 X11->ptrXFixesSelectSelectionInput(X11->display, QX11Info::appRootWindow(0),2058 XA_PRIMARY, eventMask);2059 X11->ptrXFixesSelectSelectionInput(X11->display, QX11Info::appRootWindow(0),2060 ATOM(CLIPBOARD), eventMask);2061 }2062 2028 #endif // QT_NO_XFIXES 2063 2029 … … 2079 2045 #endif // QT_RUNTIME_XCURSOR 2080 2046 #endif // QT_NO_XCURSOR 2047 2048 #ifndef QT_NO_XSYNC 2049 int xsync_evbase, xsync_errbase; 2050 int major, minor; 2051 if (XSyncQueryExtension(X11->display, &xsync_evbase, &xsync_errbase)) 2052 XSyncInitialize(X11->display, &major, &minor); 2053 #endif // QT_NO_XSYNC 2081 2054 2082 2055 #ifndef QT_NO_XINERAMA … … 2241 2214 ATOM(_NET_WM_CM_S0)); 2242 2215 X11->desktopEnvironment = DE_UNKNOWN; 2216 X11->desktopVersion = 0; 2243 2217 2244 2218 // See if the current window manager is using the freedesktop.org spec to give its name … … 2285 2259 uchar *data = 0; 2286 2260 2287 if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), 2288 0, 1, False, AnyPropertyType, &type, &format, &length, 2261 QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); 2262 if (session == QLatin1String("kde")) { 2263 X11->desktopEnvironment = DE_KDE; 2264 } else if (session == QLatin1String("gnome") || session == QLatin1String("xfce")) { 2265 X11->desktopEnvironment = DE_GNOME; 2266 } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), 2267 0, 1, False, AnyPropertyType, &type, &format, &length, 2289 2268 &after, &data) == Success && length) { 2290 2269 // DTWM is running, meaning most likely CDE is running... … … 2316 2295 } 2317 2296 2297 if (X11->desktopEnvironment == DE_KDE) 2298 X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt(); 2299 2300 #if !defined(QT_NO_STYLE_GTK) 2301 if (X11->desktopEnvironment == DE_GNOME) { 2302 static bool menusHaveIcons = QGtkStyle::getGConfBool(QLatin1String("/desktop/gnome/interface/menus_have_icons"), true); 2303 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus, !menusHaveIcons); 2304 } 2305 #endif 2318 2306 qt_set_input_encoding(); 2319 2307 … … 2351 2339 XDevice *dev = 0; 2352 2340 2353 #if !defined(Q_OS_IRIX)2354 // XFree86 divides a stylus and eraser into 2 devices, so we must do for both...2355 const QString XFREENAMESTYLUS = QLatin1String("stylus");2356 const QString XFREENAMEPEN = QLatin1String("pen");2357 const QString XFREENAMEERASER = QLatin1String("eraser");2358 #endif2359 2360 2341 if (X11->ptrXListInputDevices) { 2361 2342 devices = X11->ptrXListInputDevices(X11->display, &ndev); … … 2372 2353 gotEraser = false; 2373 2354 2355 #if defined(Q_OS_IRIX) 2374 2356 QString devName = QString::fromLocal8Bit(devs->name).toLower(); 2375 #if defined(Q_OS_IRIX)2376 2357 if (devName == QLatin1String(WACOM_NAME)) { 2377 2358 deviceType = QTabletEvent::Stylus; … … 2379 2360 } 2380 2361 #else 2381 if (devName.startsWith(XFREENAMEPEN) 2382 || devName.startsWith(XFREENAMESTYLUS)) { 2362 if (devs->type == ATOM(XWacomStylus)) { 2383 2363 deviceType = QTabletEvent::Stylus; 2364 if (wacomDeviceName()->isEmpty()) 2365 wacomDeviceName()->append(devs->name); 2384 2366 gotStylus = true; 2385 } else if (dev Name.startsWith(XFREENAMEERASER)) {2367 } else if (devs->type == ATOM(XWacomEraser)) { 2386 2368 deviceType = QTabletEvent::XFreeEraser; 2387 2369 gotEraser = true; … … 2519 2501 2520 2502 X11->startupId = getenv("DESKTOP_STARTUP_ID"); 2521 X11->originalStartupId = X11->startupId; 2522 static char desktop_startup_id[] = "DESKTOP_STARTUP_ID="; 2523 putenv(desktop_startup_id); 2524 2503 if (X11->startupId) { 2504 #ifndef QT_NO_UNSETENV 2505 unsetenv("DESKTOP_STARTUP_ID"); 2506 #else 2507 // it's a small memory leak, however we won't crash if Qt is 2508 // unloaded and someones tries to use the envoriment. 2509 putenv(strdup("DESKTOP_STARTUP_ID=")); 2510 #endif 2511 } 2525 2512 } else { 2526 2513 // read some non-GUI settings when not using the X server... … … 2576 2563 } 2577 2564 2578 2579 // run-time search for default style2580 /*!2581 \internal2582 */2583 void QApplicationPrivate::x11_initialize_style()2584 {2585 if (QApplicationPrivate::app_style)2586 return;2587 2588 switch(X11->desktopEnvironment) {2589 case DE_KDE:2590 if (X11->use_xrender)2591 QApplicationPrivate::app_style = QStyleFactory::create(QLatin1String("plastique"));2592 else2593 QApplicationPrivate::app_style = QStyleFactory::create(QLatin1String("windows"));2594 break;2595 case DE_GNOME:2596 if (X11->use_xrender)2597 QApplicationPrivate::app_style = QStyleFactory::create(QLatin1String("cleanlooks"));2598 else2599 QApplicationPrivate::app_style = QStyleFactory::create(QLatin1String("windows"));2600 break;2601 case DE_CDE:2602 QApplicationPrivate::app_style = QStyleFactory::create(QLatin1String("cde"));2603 break;2604 default:2605 // Don't do anything2606 break;2607 }2608 }2609 2610 2565 void QApplicationPrivate::initializeWidgetPaletteHash() 2611 2566 { … … 2635 2590 #endif 2636 2591 } 2637 2638 // restore original value back. This is also done in QWidgetPrivate::show_sys.2639 if (X11->originalStartupId)2640 putenv(X11->originalStartupId);2641 2592 2642 2593 #ifndef QT_NO_XRENDER … … 2843 2794 *****************************************************************************/ 2844 2795 2845 extern void qt_x11_enforce_cursor(QWidget * w);2846 2847 2796 void QApplication::setOverrideCursor(const QCursor &cursor) 2848 2797 { … … 2950 2899 while (ctarget && !w) { 2951 2900 X11->ignoreBadwindow(); 2952 XTranslateCoordinates(X11->display,2953 QX11Info::appRootWindow(screen),2954 ctarget, x, y, &unused, &unused, &ctarget);2955 if (X11->badwindow())2901 if (!XTranslateCoordinates(X11->display, 2902 QX11Info::appRootWindow(screen), 2903 ctarget, x, y, &unused, &unused, &ctarget) 2904 || X11->badwindow()) 2956 2905 break; 2957 2906 if (ctarget == wid) { … … 2971 2920 } 2972 2921 2973 /*!2974 Synchronizes with the X server in the X11 implementation. This2975 normally takes some time. Does nothing on other platforms.2976 */2977 2978 2922 void QApplication::syncX() 2979 2923 { 2980 2924 if (X11->display) 2981 XSync(X11->display, False); 2925 XSync(X11->display, False); // don't discard events 2982 2926 } 2983 2927 … … 3081 3025 } 3082 3026 3083 /*!3084 \internal3085 */3086 3027 int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) 3087 3028 { … … 3120 3061 False, SubstructureNotifyMask|SubstructureRedirectMask, event); 3121 3062 } 3063 #ifndef QT_NO_XSYNC 3064 } else if (a == ATOM(_NET_WM_SYNC_REQUEST)) { 3065 const ulong timestamp = (const ulong) event->xclient.data.l[1]; 3066 if (timestamp > X11->time) 3067 X11->time = timestamp; 3068 if (QTLWExtra *tlw = w->d_func()->maybeTopData()) { 3069 if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) { 3070 tlw->syncRequestTimestamp = timestamp; 3071 tlw->newCounterValueLo = event->xclient.data.l[2]; 3072 tlw->newCounterValueHi = event->xclient.data.l[3]; 3073 } 3074 } 3075 #endif 3122 3076 } 3123 3077 } else if (event->xclient.message_type == ATOM(_QT_SCROLL_DONE)) { … … 3146 3100 } 3147 3101 3148 /*!3149 This function does the core processing of individual X3150 \a{event}s, normally by dispatching Qt events to the right3151 destination.3152 3153 It returns 1 if the event was consumed by special handling, 0 if3154 the \a event was consumed by normal handling, and -1 if the \a3155 event was for an unrecognized widget.3156 3157 \sa x11EventFilter()3158 */3159 3102 int QApplication::x11ProcessEvent(XEvent* event) 3160 3103 { 3161 3104 Q_D(QApplication); 3162 3105 QScopedLoopLevelCounter loopLevelCounter(d->threadData); 3106 3163 3107 #ifdef ALIEN_DEBUG 3164 3108 //qDebug() << "QApplication::x11ProcessEvent:" << event->type; … … 3366 3310 w->data->crect.setWidth(DisplayWidth(X11->display, scr)); 3367 3311 w->data->crect.setHeight(DisplayHeight(X11->display, scr)); 3368 QVarLengthArray<QRect> oldSizes(desktop->numScreens());3369 for (int i = 0; i < desktop->numScreens(); ++i)3370 oldSizes[i] = desktop->screenGeometry(i);3371 3312 QResizeEvent e(w->size(), oldSize); 3372 3313 QApplication::sendEvent(w, &e); 3373 for (int i = 0; i < qMin(oldSizes.count(), desktop->numScreens()); ++i) { 3374 if (oldSizes[i] != desktop->screenGeometry(i)) 3375 emit desktop->resized(i); 3376 } 3377 for (int i = oldSizes.count(); i < desktop->numScreens(); ++i) 3378 emit desktop->resized(i); // added 3379 for (int i = desktop->numScreens(); i < oldSizes.count(); ++i) 3380 emit desktop->resized(i); // removed 3314 if (w != desktop) 3315 QApplication::sendEvent(desktop, &e); 3381 3316 } 3382 3317 #endif // QT_NO_XRANDR … … 3818 3753 } else if (event->xproperty.atom == ATOM(_NET_WORKAREA)) { 3819 3754 qt_desktopwidget_update_workarea(); 3755 3756 // emit the workAreaResized() signal 3757 QDesktopWidget *desktop = QApplication::desktop(); 3758 int numScreens = desktop->numScreens(); 3759 for (int i = 0; i < numScreens; ++i) 3760 emit desktop->workAreaResized(i); 3820 3761 } 3821 3762 } else if (widget) { … … 3832 3773 return 0; 3833 3774 } 3834 3835 /*!3836 \fn bool QApplication::x11EventFilter(XEvent *event)3837 3838 \warning This virtual function is only implemented under X11.3839 3840 If you create an application that inherits QApplication and3841 reimplement this function, you get direct access to all X events3842 that the are received from the X server. The events are passed in3843 the \a event parameter.3844 3845 Return true if you want to stop the event from being processed.3846 Return false for normal event dispatching. The default3847 implementation returns false.3848 3849 It is only the directly addressed messages that are filtered.3850 You must install an event filter directly on the event3851 dispatcher, which is returned by3852 QAbstractEventDispatcher::instance(), to handle system wide3853 messages.3854 3855 \sa x11ProcessEvent()3856 */3857 3775 3858 3776 bool QApplication::x11EventFilter(XEvent *) … … 4177 4095 && qt_button_down == this) 4178 4096 || (nextEvent.type == ClientMessage 4179 && nextEvent.xclient.message_type == ATOM(_QT_SCROLL_DONE))) { 4097 && (nextEvent.xclient.message_type == ATOM(_QT_SCROLL_DONE) || 4098 (nextEvent.xclient.message_type == ATOM(WM_PROTOCOLS) && 4099 (Atom)nextEvent.xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST))))) { 4180 4100 qApp->x11ProcessEvent(&nextEvent); 4181 4101 continue; … … 4447 4367 QApplicationPrivate::sendMouseEvent(widget, &e, alienWidget, this, &qt_button_down, 4448 4368 qt_last_mouse_receiver); 4449 4450 4369 if (type == QEvent::MouseButtonPress 4451 4370 && button == Qt::RightButton … … 4516 4435 if (config == 0) 4517 4436 return; 4518 const char *name = "stylus"; // TODO get this from the X config instead (users may have called it differently) 4519 WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, name); 4437 WACOMDEVICE *device = ptrWacomConfigOpenDevice (config, wacomDeviceName()->constData()); 4520 4438 if (device == 0) 4521 4439 return; … … 4575 4493 #endif 4576 4494 4495 struct qt_tablet_motion_data 4496 { 4497 bool filterByWidget; 4498 const QWidget *widget; 4499 const QWidget *etWidget; 4500 int tabletMotionType; 4501 bool error; // found a reason to stop searching 4502 }; 4503 4504 static Bool qt_mouseMotion_scanner(Display *, XEvent *event, XPointer arg) 4505 { 4506 qt_tablet_motion_data *data = (qt_tablet_motion_data *) arg; 4507 if (data->error) 4508 return false; 4509 4510 if (event->type == MotionNotify) 4511 return true; 4512 4513 data->error = event->type != data->tabletMotionType; // we stop compression when another event gets in between. 4514 return false; 4515 } 4516 4517 static Bool qt_tabletMotion_scanner(Display *, XEvent *event, XPointer arg) 4518 { 4519 qt_tablet_motion_data *data = (qt_tablet_motion_data *) arg; 4520 if (data->error) 4521 return false; 4522 if (event->type == data->tabletMotionType) { 4523 const XDeviceMotionEvent *const motion = reinterpret_cast<const XDeviceMotionEvent*>(event); 4524 if (data->filterByWidget) { 4525 const QPoint curr(motion->x, motion->y); 4526 const QWidget *w = data->etWidget; 4527 const QWidget *const child = w->childAt(curr); 4528 if (child) { 4529 w = child; 4530 } 4531 if (w == data->widget) 4532 return true; 4533 } else { 4534 return true; 4535 } 4536 } 4537 4538 data->error = event->type != MotionNotify; // we stop compression when another event gets in between. 4539 return false; 4540 } 4541 4577 4542 bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet) 4578 4543 { … … 4601 4566 int deviceType = QTabletEvent::NoDevice; 4602 4567 int pointerType = QTabletEvent::UnknownPointer; 4603 XEvent xinputMotionEvent;4604 XEvent mouseMotionEvent;4605 4568 const XDeviceMotionEvent *motion = 0; 4606 4569 XDeviceButtonEvent *button = 0; … … 4608 4571 QEvent::Type t; 4609 4572 Qt::KeyboardModifiers modifiers = 0; 4610 bool reinsertMouseEvent = false;4611 bool neverFoundMouseEvent = true;4612 XEvent xinputMotionEventNext;4613 XEvent mouseMotionEventSave;4614 4573 #if !defined (Q_OS_IRIX) 4615 4574 XID device_id; … … 4618 4577 if (ev->type == tablet->xinput_motion) { 4619 4578 motion = reinterpret_cast<const XDeviceMotionEvent*>(ev); 4620 for (;;) {4621 // get the corresponding mouseMotionEvent for motion4622 if (XCheckTypedWindowEvent(X11->display, internalWinId(), MotionNotify, &mouseMotionEvent)) {4623 mouseMotionEventSave = mouseMotionEvent;4624 reinsertMouseEvent = true;4625 neverFoundMouseEvent = false;4626 4627 if (mouseMotionEvent.xmotion.time > motion->time) {4628 XEvent xinputMotionEventLoop = *ev;4629 4630 // xinput event is older than the mouse event --> search for the corresponding xinput event for the given mouse event4631 while (mouseMotionEvent.xmotion.time > (reinterpret_cast<const XDeviceMotionEvent*>(&xinputMotionEventLoop))->time) {4632 if (XCheckTypedWindowEvent(X11->display, internalWinId(), tablet->xinput_motion, &xinputMotionEventLoop)) {4633 xinputMotionEvent = xinputMotionEventLoop;4634 }4635 else {4636 break;4637 }4638 }4639 motion = reinterpret_cast<const XDeviceMotionEvent*>(&xinputMotionEvent);4640 }4641 4642 // get the next xinputMotionEvent, for the next loop run4643 if (!XCheckTypedWindowEvent(X11->display, internalWinId(), tablet->xinput_motion, &xinputMotionEventNext)) {4644 XPutBackEvent(X11->display, &mouseMotionEvent);4645 reinsertMouseEvent = false;4646 break;4647 }4648 4649 if (mouseMotionEvent.xmotion.time != motion->time) {4650 // reinsert in order4651 if (mouseMotionEvent.xmotion.time >= motion->time) {4652 XPutBackEvent(X11->display, &mouseMotionEvent);4653 XPutBackEvent(X11->display, &xinputMotionEventNext);4654 // next entry in queue is xinputMotionEventNext4655 }4656 else {4657 XPutBackEvent(X11->display, &xinputMotionEventNext);4658 XPutBackEvent(X11->display, &mouseMotionEvent);4659 // next entry in queue is mouseMotionEvent4660 }4661 reinsertMouseEvent = false;4662 break;4663 }4664 }4665 else {4666 break;4667 }4668 4669 xinputMotionEvent = xinputMotionEventNext;4670 motion = (reinterpret_cast<const XDeviceMotionEvent*>(&xinputMotionEvent));4671 }4672 4673 if (reinsertMouseEvent) {4674 XPutBackEvent(X11->display, &mouseMotionEventSave);4675 }4676 4677 if (neverFoundMouseEvent) {4678 XEvent xinputMotionEventLoop;4679 bool eventFound = false;4680 // xinput event without mouseMotionEvent --> search the newest xinputMotionEvent4681 while (XCheckTypedWindowEvent(X11->display, internalWinId(), tablet->xinput_motion, &xinputMotionEventLoop)) {4682 xinputMotionEvent = xinputMotionEventLoop;4683 eventFound = true;4684 }4685 if (eventFound) motion = reinterpret_cast<const XDeviceMotionEvent*>(&xinputMotionEvent);4686 }4687 4688 4579 t = QEvent::TabletMove; 4689 4580 global = QPoint(motion->x_root, motion->y_root); … … 4838 4729 #endif 4839 4730 4840 QWidget *child = w->childAt(curr); 4841 if (child) { 4842 w = child; 4843 curr = w->mapFromGlobal(global); 4844 } 4731 if (tablet->widgetToGetPress) { 4732 w = tablet->widgetToGetPress; 4733 } else { 4734 QWidget *child = w->childAt(curr); 4735 if (child) 4736 w = child; 4737 } 4738 curr = w->mapFromGlobal(global); 4845 4739 4846 4740 if (t == QEvent::TabletPress) { … … 4856 4750 qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)), 4857 4751 xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid); 4858 if (proximity) 4752 if (proximity) { 4859 4753 QApplication::sendSpontaneousEvent(qApp, &e); 4860 else4754 } else { 4861 4755 QApplication::sendSpontaneousEvent(w, &e); 4756 const bool accepted = e.isAccepted(); 4757 if (!accepted && ev->type == tablet->xinput_motion) { 4758 // If the widget does not accept tablet events, we drop the next ones from the event queue 4759 // for this widget so it is not overloaded with the numerous tablet events. 4760 qt_tablet_motion_data tabletMotionData; 4761 tabletMotionData.tabletMotionType = tablet->xinput_motion; 4762 tabletMotionData.widget = w; 4763 tabletMotionData.etWidget = this; 4764 // if nothing is pressed, the events are filtered by position 4765 tabletMotionData.filterByWidget = (tablet->widgetToGetPress == 0); 4766 4767 bool reinsertMouseEvent = false; 4768 XEvent mouseMotionEvent; 4769 while (true) { 4770 // Find first mouse event since we expect them in pairs inside Qt 4771 tabletMotionData.error =false; 4772 if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) { 4773 reinsertMouseEvent = true; 4774 } else { 4775 break; 4776 } 4777 4778 // Now discard any duplicate tablet events. 4779 tabletMotionData.error = false; 4780 XEvent dummy; 4781 while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) { 4782 // just discard the event 4783 } 4784 } 4785 4786 if (reinsertMouseEvent) { 4787 XPutBackEvent(X11->display, &mouseMotionEvent); 4788 } 4789 } 4790 } 4862 4791 return true; 4863 4792 } … … 5056 4985 } 5057 4986 4987 5058 4988 // 5059 4989 // Paint event translation … … 5234 5164 } 5235 5165 } 5166 #ifndef QT_NO_XSYNC 5167 qt_sync_request_event_data sync_event; 5168 sync_event.window = internalWinId(); 5169 for (XEvent ev;;) { 5170 if (!XCheckIfEvent(X11->display, &ev, &qt_sync_request_scanner, (XPointer)&sync_event)) 5171 break; 5172 } 5173 #endif // QT_NO_XSYNC 5236 5174 } 5237 5175 … … 5319 5257 d->extra->topextra->inTopLevelResize = false; 5320 5258 } 5259 #ifndef QT_NO_XSYNC 5260 if (QTLWExtra *tlwExtra = d->maybeTopData()) { 5261 if (tlwExtra->newCounterValueLo != 0 || tlwExtra->newCounterValueHi != 0) { 5262 XSyncValue value; 5263 XSyncIntsToValue(&value, 5264 tlwExtra->newCounterValueLo, 5265 tlwExtra->newCounterValueHi); 5266 5267 XSyncSetCounter(X11->display, tlwExtra->syncUpdateCounter, value); 5268 tlwExtra->newCounterValueHi = 0; 5269 tlwExtra->newCounterValueLo = 0; 5270 } 5271 } 5272 #endif 5321 5273 return true; 5322 5274 } … … 5442 5394 public: 5443 5395 QSessionManagerPrivate(QSessionManager* mgr, QString& id, QString& key) 5444 : QObjectPrivate(), sm(mgr), sessionId(id), sessionKey(key), eventLoop(0) {} 5396 : QObjectPrivate(), sm(mgr), sessionId(id), sessionKey(key), 5397 restartHint(QSessionManager::RestartIfRunning), eventLoop(0) {} 5445 5398 QSessionManager* sm; 5446 5399 QStringList restartCommand; … … 5935 5888 #endif // QT_NO_SESSIONMANAGER 5936 5889 5890 #if defined(QT_RX71_MULTITOUCH) 5891 5892 static inline int testBit(const char *array, int bit) 5893 { 5894 return (array[bit/8] & (1<<(bit%8))); 5895 } 5896 5897 static int openRX71Device(const QByteArray &deviceName) 5898 { 5899 int fd = open(deviceName, O_RDONLY | O_NONBLOCK); 5900 if (fd == -1) { 5901 fd = -errno; 5902 return fd; 5903 } 5904 5905 // fetch the event type mask and check that the device reports absolute coordinates 5906 char eventTypeMask[(EV_MAX + sizeof(char) - 1) * sizeof(char) + 1]; 5907 memset(eventTypeMask, 0, sizeof(eventTypeMask)); 5908 if (ioctl(fd, EVIOCGBIT(0, sizeof(eventTypeMask)), eventTypeMask) < 0) { 5909 close(fd); 5910 return -1; 5911 } 5912 if (!testBit(eventTypeMask, EV_ABS)) { 5913 close(fd); 5914 return -1; 5915 } 5916 5917 // make sure that we can get the absolute X and Y positions from the device 5918 char absMask[(ABS_MAX + sizeof(char) - 1) * sizeof(char) + 1]; 5919 memset(absMask, 0, sizeof(absMask)); 5920 if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absMask)), absMask) < 0) { 5921 close(fd); 5922 return -1; 5923 } 5924 if (!testBit(absMask, ABS_X) || !testBit(absMask, ABS_Y)) { 5925 close(fd); 5926 return -1; 5927 } 5928 5929 return fd; 5930 } 5931 5932 void QApplicationPrivate::initializeMultitouch_sys() 5933 { 5934 Q_Q(QApplication); 5935 5936 QByteArray deviceName = QByteArray("/dev/input/event"); 5937 int currentDeviceNumber = 0; 5938 for (;;) { 5939 int fd = openRX71Device(QByteArray(deviceName + QByteArray::number(currentDeviceNumber++))); 5940 if (fd == -ENOENT) { 5941 // no more devices 5942 break; 5943 } 5944 if (fd < 0) { 5945 // not a touch device 5946 continue; 5947 } 5948 5949 struct input_absinfo abs_x, abs_y, abs_z; 5950 ioctl(fd, EVIOCGABS(ABS_X), &abs_x); 5951 ioctl(fd, EVIOCGABS(ABS_Y), &abs_y); 5952 ioctl(fd, EVIOCGABS(ABS_Z), &abs_z); 5953 5954 int deviceNumber = allRX71TouchPoints.count(); 5955 5956 QSocketNotifier *socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, q); 5957 QObject::connect(socketNotifier, SIGNAL(activated(int)), q, SLOT(_q_readRX71MultiTouchEvents())); 5958 5959 RX71TouchPointState touchPointState = { 5960 socketNotifier, 5961 QTouchEvent::TouchPoint(deviceNumber), 5962 5963 abs_x.minimum, abs_x.maximum, q->desktop()->screenGeometry().width(), 5964 abs_y.minimum, abs_y.maximum, q->desktop()->screenGeometry().height(), 5965 abs_z.minimum, abs_z.maximum 5966 }; 5967 allRX71TouchPoints.append(touchPointState); 5968 } 5969 5970 hasRX71MultiTouch = allRX71TouchPoints.count() > 1; 5971 if (!hasRX71MultiTouch) { 5972 for (int i = 0; i < allRX71TouchPoints.count(); ++i) { 5973 QSocketNotifier *socketNotifier = allRX71TouchPoints.at(i).socketNotifier; 5974 close(socketNotifier->socket()); 5975 delete socketNotifier; 5976 } 5977 allRX71TouchPoints.clear(); 5978 } 5979 } 5980 5981 void QApplicationPrivate::cleanupMultitouch_sys() 5982 { 5983 hasRX71MultiTouch = false; 5984 for (int i = 0; i < allRX71TouchPoints.count(); ++i) { 5985 QSocketNotifier *socketNotifier = allRX71TouchPoints.at(i).socketNotifier; 5986 close(socketNotifier->socket()); 5987 delete socketNotifier; 5988 } 5989 allRX71TouchPoints.clear(); 5990 } 5991 5992 bool QApplicationPrivate::readRX71MultiTouchEvents(int deviceNumber) 5993 { 5994 RX71TouchPointState &touchPointState = allRX71TouchPoints[deviceNumber]; 5995 QSocketNotifier *socketNotifier = touchPointState.socketNotifier; 5996 int fd = socketNotifier->socket(); 5997 5998 QTouchEvent::TouchPoint &touchPoint = touchPointState.touchPoint; 5999 6000 bool down = touchPoint.state() != Qt::TouchPointReleased; 6001 if (down) 6002 touchPoint.setState(Qt::TouchPointStationary); 6003 6004 bool changed = false; 6005 for (;;) { 6006 struct input_event inputEvent; 6007 int bytesRead = read(fd, &inputEvent, sizeof(inputEvent)); 6008 if (bytesRead <= 0) 6009 break; 6010 if (bytesRead != sizeof(inputEvent)) { 6011 qWarning("Qt: INTERNAL ERROR: short read in readRX71MultiTouchEvents()"); 6012 return false; 6013 } 6014 6015 switch (inputEvent.type) { 6016 case EV_SYN: 6017 changed = true; 6018 switch (touchPoint.state()) { 6019 case Qt::TouchPointPressed: 6020 case Qt::TouchPointReleased: 6021 // make sure we don't compress pressed and releases with any other events 6022 return changed; 6023 default: 6024 break; 6025 } 6026 continue; 6027 case EV_KEY: 6028 case EV_ABS: 6029 break; 6030 default: 6031 qWarning("Qt: WARNING: unknown event type %d on multitouch device", inputEvent.type); 6032 continue; 6033 } 6034 6035 QPointF screenPos = touchPoint.screenPos(); 6036 switch (inputEvent.code) { 6037 case BTN_TOUCH: 6038 if (!down && inputEvent.value != 0) 6039 touchPoint.setState(Qt::TouchPointPressed); 6040 else if (down && inputEvent.value == 0) 6041 touchPoint.setState(Qt::TouchPointReleased); 6042 break; 6043 case ABS_TOOL_WIDTH: 6044 case ABS_VOLUME: 6045 case ABS_PRESSURE: 6046 // ignore for now 6047 break; 6048 case ABS_X: 6049 { 6050 qreal newValue = ((qreal(inputEvent.value - touchPointState.minX) 6051 / qreal(touchPointState.maxX - touchPointState.minX)) 6052 * touchPointState.scaleX); 6053 screenPos.rx() = newValue; 6054 touchPoint.setScreenPos(screenPos); 6055 break; 6056 } 6057 case ABS_Y: 6058 { 6059 qreal newValue = ((qreal(inputEvent.value - touchPointState.minY) 6060 / qreal(touchPointState.maxY - touchPointState.minY)) 6061 * touchPointState.scaleY); 6062 screenPos.ry() = newValue; 6063 touchPoint.setScreenPos(screenPos); 6064 break; 6065 } 6066 case ABS_Z: 6067 { 6068 // map Z (signal strength) to pressure for now 6069 qreal newValue = (qreal(inputEvent.value - touchPointState.minZ) 6070 / qreal(touchPointState.maxZ - touchPointState.minZ)); 6071 touchPoint.setPressure(newValue); 6072 break; 6073 } 6074 default: 6075 qWarning("Qt: WARNING: unknown event code %d on multitouch device", inputEvent.code); 6076 continue; 6077 } 6078 } 6079 6080 if (down && touchPoint.state() != Qt::TouchPointReleased) 6081 touchPoint.setState(changed ? Qt::TouchPointMoved : Qt::TouchPointStationary); 6082 6083 return changed; 6084 } 6085 6086 void QApplicationPrivate::_q_readRX71MultiTouchEvents() 6087 { 6088 // read touch events from all devices 6089 bool changed = false; 6090 for (int i = 0; i < allRX71TouchPoints.count(); ++i) 6091 changed = readRX71MultiTouchEvents(i) || changed; 6092 if (!changed) 6093 return; 6094 6095 QList<QTouchEvent::TouchPoint> touchPoints; 6096 for (int i = 0; i < allRX71TouchPoints.count(); ++i) 6097 touchPoints.append(allRX71TouchPoints.at(i).touchPoint); 6098 6099 translateRawTouchEvent(0, QTouchEvent::TouchScreen, touchPoints); 6100 } 6101 6102 #else // !QT_RX71_MULTITOUCH 6103 6104 void QApplicationPrivate::initializeMultitouch_sys() 6105 { } 6106 void QApplicationPrivate::cleanupMultitouch_sys() 6107 { } 6108 6109 #endif // QT_RX71_MULTITOUCH 6110 5937 6111 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.