src/gui/kernel/qapplication_x11.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    94 #   include <wacomcfg.h>
    94 #   include <wacomcfg.h>
    95 #   undef class
    95 #   undef class
    96 }
    96 }
    97 #endif
    97 #endif
    98 
    98 
       
    99 #ifndef QT_GUI_DOUBLE_CLICK_RADIUS
       
   100 #define QT_GUI_DOUBLE_CLICK_RADIUS 5
       
   101 #endif
       
   102 
       
   103 
    99 //#define ALIEN_DEBUG
   104 //#define ALIEN_DEBUG
   100 
   105 
   101 #if !defined(QT_NO_GLIB)
   106 #if !defined(QT_NO_GLIB)
   102 #  include "qguieventdispatcher_glib_p.h"
   107 #  include "qguieventdispatcher_glib_p.h"
   103 #endif
   108 #endif
   313 
   318 
   314     // XEMBED
   319     // XEMBED
   315     "_XEMBED\0"
   320     "_XEMBED\0"
   316     "_XEMBED_INFO\0"
   321     "_XEMBED_INFO\0"
   317 
   322 
       
   323     // Wacom old. (before version 0.10)
   318     "Wacom Stylus\0"
   324     "Wacom Stylus\0"
   319     "Wacom Cursor\0"
   325     "Wacom Cursor\0"
   320     "Wacom Eraser\0"
   326     "Wacom Eraser\0"
       
   327 
       
   328     // Tablet
       
   329     "STYLUS\0"
       
   330     "ERASER\0"
   321 };
   331 };
   322 
   332 
   323 Q_GUI_EXPORT QX11Data *qt_x11Data = 0;
   333 Q_GUI_EXPORT QX11Data *qt_x11Data = 0;
   324 
   334 
   325 /*****************************************************************************
   335 /*****************************************************************************
   942     num =
   952     num =
   943         settings.value(QLatin1String("cursorFlashTime"),
   953         settings.value(QLatin1String("cursorFlashTime"),
   944                        QApplication::cursorFlashTime()).toInt();
   954                        QApplication::cursorFlashTime()).toInt();
   945     QApplication::setCursorFlashTime(num);
   955     QApplication::setCursorFlashTime(num);
   946 
   956 
       
   957 #ifndef QT_NO_WHEELEVENT
   947     num =
   958     num =
   948         settings.value(QLatin1String("wheelScrollLines"),
   959         settings.value(QLatin1String("wheelScrollLines"),
   949                        QApplication::wheelScrollLines()).toInt();
   960                        QApplication::wheelScrollLines()).toInt();
   950     QApplication::setWheelScrollLines(num);
   961     QApplication::setWheelScrollLines(num);
       
   962 #endif
   951 
   963 
   952     QString colorspec = settings.value(QLatin1String("colorSpec"),
   964     QString colorspec = settings.value(QLatin1String("colorSpec"),
   953                                        QVariant(QLatin1String("default"))).toString();
   965                                        QVariant(QLatin1String("default"))).toString();
   954     if (colorspec == QLatin1String("normal"))
   966     if (colorspec == QLatin1String("normal"))
   955         QApplication::setColorSpec(QApplication::NormalColor);
   967         QApplication::setColorSpec(QApplication::NormalColor);
  2357                 if (devName == QLatin1String(WACOM_NAME)) {
  2369                 if (devName == QLatin1String(WACOM_NAME)) {
  2358                     deviceType = QTabletEvent::Stylus;
  2370                     deviceType = QTabletEvent::Stylus;
  2359                     gotStylus = true;
  2371                     gotStylus = true;
  2360                 }
  2372                 }
  2361 #else
  2373 #else
  2362                 if (devs->type == ATOM(XWacomStylus)) {
  2374                 if (devs->type == ATOM(XWacomStylus) || devs->type == ATOM(XTabletStylus)) {
  2363                     deviceType = QTabletEvent::Stylus;
  2375                     deviceType = QTabletEvent::Stylus;
  2364                     if (wacomDeviceName()->isEmpty())
  2376                     if (wacomDeviceName()->isEmpty())
  2365                         wacomDeviceName()->append(devs->name);
  2377                         wacomDeviceName()->append(devs->name);
  2366                     gotStylus = true;
  2378                     gotStylus = true;
  2367                 } else if (devs->type == ATOM(XWacomEraser)) {
  2379                 } else if (devs->type == ATOM(XWacomEraser) || devs->type == ATOM(XTabletEraser)) {
  2368                     deviceType = QTabletEvent::XFreeEraser;
  2380                     deviceType = QTabletEvent::XFreeEraser;
  2369                     gotEraser = true;
  2381                     gotEraser = true;
  2370                 }
  2382                 }
  2371 #endif
  2383 #endif
  2372                 if (deviceType == QTabletEvent::NoDevice)
  2384                 if (deviceType == QTabletEvent::NoDevice)
  4211             }
  4223             }
  4212             if (mouseActWindow == event->xbutton.window &&
  4224             if (mouseActWindow == event->xbutton.window &&
  4213                 mouseButtonPressed == button &&
  4225                 mouseButtonPressed == button &&
  4214                 (long)event->xbutton.time -(long)mouseButtonPressTime
  4226                 (long)event->xbutton.time -(long)mouseButtonPressTime
  4215                 < QApplication::doubleClickInterval() &&
  4227                 < QApplication::doubleClickInterval() &&
  4216                 qAbs(event->xbutton.x - mouseXPos) < 5 &&
  4228                 qAbs(event->xbutton.x - mouseXPos) < QT_GUI_DOUBLE_CLICK_RADIUS &&
  4217                 qAbs(event->xbutton.y - mouseYPos) < 5) {
  4229                 qAbs(event->xbutton.y - mouseYPos) < QT_GUI_DOUBLE_CLICK_RADIUS) {
  4218                 type = QEvent::MouseButtonDblClick;
  4230                 type = QEvent::MouseButtonDblClick;
  4219                 mouseButtonPressTime -= 2000;        // no double-click next time
  4231                 mouseButtonPressTime -= 2000;        // no double-click next time
  4220             } else {
  4232             } else {
  4221                 type = QEvent::MouseButtonPress;
  4233                 type = QEvent::MouseButtonPress;
  4222                 mouseButtonPressTime = event->xbutton.time;
  4234                 mouseButtonPressTime = event->xbutton.time;
  4399     // send the event to the widget or its ancestors
  4411     // send the event to the widget or its ancestors
  4400     {
  4412     {
  4401         QWidget* popup = qApp->activePopupWidget();
  4413         QWidget* popup = qApp->activePopupWidget();
  4402         if (popup && window() != popup)
  4414         if (popup && window() != popup)
  4403             popup->close();
  4415             popup->close();
       
  4416 #ifndef QT_NO_WHEELEVENT
  4404         QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
  4417         QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
  4405         if (QApplication::sendSpontaneousEvent(widget, &e))
  4418         if (QApplication::sendSpontaneousEvent(widget, &e))
       
  4419 #endif
  4406             return true;
  4420             return true;
  4407     }
  4421     }
  4408 
  4422 
  4409     // send the event to the widget that has the focus or its ancestors, if different
  4423     // send the event to the widget that has the focus or its ancestors, if different
  4410     if (widget != qApp->focusWidget() && (widget = qApp->focusWidget())) {
  4424     if (widget != qApp->focusWidget() && (widget = qApp->focusWidget())) {
  4411         if (widget && !widget->internalWinId())
  4425         if (widget && !widget->internalWinId())
  4412             pos = widget->mapFromGlobal(globalPos);
  4426             pos = widget->mapFromGlobal(globalPos);
  4413         QWidget* popup = qApp->activePopupWidget();
  4427         QWidget* popup = qApp->activePopupWidget();
  4414         if (popup && widget != popup)
  4428         if (popup && widget != popup)
  4415             popup->hide();
  4429             popup->hide();
       
  4430 #ifndef QT_NO_WHEELEVENT
  4416         QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
  4431         QWheelEvent e(pos, globalPos, delta, buttons, modifiers, orient);
  4417         if (QApplication::sendSpontaneousEvent(widget, &e))
  4432         if (QApplication::sendSpontaneousEvent(widget, &e))
       
  4433 #endif
  4418             return true;
  4434             return true;
  4419     }
  4435     }
  4420     return false;
  4436     return false;
  4421 }
  4437 }
  4422 
  4438 
  5311 int QApplication::keyboardInputInterval()
  5327 int QApplication::keyboardInputInterval()
  5312 {
  5328 {
  5313     return QApplicationPrivate::keyboard_input_time;
  5329     return QApplicationPrivate::keyboard_input_time;
  5314 }
  5330 }
  5315 
  5331 
       
  5332 #ifndef QT_NO_WHEELEVENT
  5316 void QApplication::setWheelScrollLines(int n)
  5333 void QApplication::setWheelScrollLines(int n)
  5317 {
  5334 {
  5318     QApplicationPrivate::wheel_scroll_lines = n;
  5335     QApplicationPrivate::wheel_scroll_lines = n;
  5319 }
  5336 }
  5320 
  5337 
  5321 int QApplication::wheelScrollLines()
  5338 int QApplication::wheelScrollLines()
  5322 {
  5339 {
  5323     return QApplicationPrivate::wheel_scroll_lines;
  5340     return QApplicationPrivate::wheel_scroll_lines;
  5324 }
  5341 }
       
  5342 #endif
  5325 
  5343 
  5326 void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
  5344 void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
  5327 {
  5345 {
  5328     switch (effect) {
  5346     switch (effect) {
  5329     case Qt::UI_AnimateMenu:
  5347     case Qt::UI_AnimateMenu: