OSDN Git Service

various cleanups
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 30 Sep 2016 03:42:07 +0000 (03:42 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 30 Sep 2016 03:42:07 +0000 (03:42 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/kernel/qapplication_x11.cpp
src/gui/kernel/qtooltip.cpp
src/gui/kernel/qwhatsthis.cpp
src/gui/kernel/qwidget.cpp
src/gui/kernel/qwidget_p.h
src/gui/kernel/qwidget_x11.cpp
src/gui/kernel/qwindowdefs.h
src/gui/kernel/qx11info_x11.h
src/gui/widgets/qabstractspinbox.cpp
src/gui/widgets/qworkspace.cpp

index c5af5fa..74e0a4d 100644 (file)
@@ -557,7 +557,7 @@ static Bool qt_xfixes_scanner(Display*, XEvent *event, XPointer arg)
 class QETWidget : public QWidget                // event translator widget
 {
 public:
-    QWidgetPrivate* d_func() { return QWidget::d_func(); }
+    inline QWidgetPrivate* d_func() { return QWidget::d_func(); }
     bool translateMouseEvent(const XEvent *);
     void translatePaintEvent(const XEvent *);
     bool translateConfigEvent(const XEvent *);
index 3e33d08..28da111 100644 (file)
@@ -38,9 +38,6 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
-#ifdef Q_WS_MAC
-# include <qcore_mac_p.h>
-#endif
 
 #include <qapplication.h>
 #include <qdesktopwidget.h>
 #include <qbasictimer.h>
 #ifndef QT_NO_TOOLTIP
 
-#ifdef Q_WS_MAC
-# include <qcore_mac_p.h>
-#include <qt_cocoa_helpers_mac_p.h>
-#endif
-
 QT_BEGIN_NAMESPACE
 
 /*!
@@ -343,15 +335,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
 #endif //QT_NO_STYLE_STYLESHEET
 
     const QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w));
-
-    QPoint p = pos;
-    p += QPoint(2,
-#ifdef Q_WS_WIN
-                21
-#else
-                16
-#endif
-        );
+    QPoint p = pos + QPoint(2, 16);
     if (p.x() + this->width() > screen.x() + screen.width())
         p.rx() -= 4 + this->width();
     if (p.y() + this->height() > screen.y() + screen.height())
index 4d6d3e9..6e20742 100644 (file)
 #ifndef QT_NO_ACCESSIBILITY
 #include "qaccessible.h"
 #endif
-#if defined(Q_WS_WIN)
-#include "qt_windows.h"
-#ifndef SPI_GETDROPSHADOW
-#define SPI_GETDROPSHADOW                   0x1024
-#endif
-#endif
 #if defined(Q_WS_X11)
 #include "qx11info_x11.h"
 #include <qwidget.h>
@@ -223,15 +217,6 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
                                         + Qt::TextWordWrap + Qt::TextExpandTabs,
                                         text);
     }
-#if defined(Q_WS_WIN)
-    if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
-        && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
-    {
-        BOOL shadow;
-        SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
-        shadowWidth = shadow ? 0 : 6;
-    }
-#endif
     resize(r.width() + 2*hMargin + shadowWidth, r.height() + 2*vMargin + shadowWidth);
 }
 
@@ -300,23 +285,9 @@ void QWhatsThat::keyPressEvent(QKeyEvent*)
 
 void QWhatsThat::paintEvent(QPaintEvent*)
 {
-    bool drawShadow = true;
-#if defined(Q_WS_WIN)
-    if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
-        && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
-    {
-        BOOL shadow;
-        SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
-        drawShadow = !shadow;
-    }
-#elif defined(Q_WS_MAC)
-    drawShadow = false; // never draw it on OS X, as we get it for free
-#endif
-
     QRect r = rect();
     r.adjust(0, 0, -1, -1);
-    if (drawShadow)
-        r.adjust(0, 0, -shadowWidth, -shadowWidth);
+    r.adjust(0, 0, -shadowWidth, -shadowWidth);
     QPainter p(this);
     p.drawPixmap(0, 0, background);
     p.setPen(QPen(palette().toolTipText(), 0));
@@ -326,19 +297,20 @@ void QWhatsThat::paintEvent(QPaintEvent*)
     int h = r.height();
     p.setPen(palette().brush(QPalette::Dark).color());
     p.drawRect(1, 1, w-2, h-2);
-    if (drawShadow) {
-        p.setPen(palette().shadow().color());
-        p.drawPoint(w + 5, 6);
-        p.drawLine(w + 3, 6, w + 5, 8);
-        p.drawLine(w + 1, 6, w + 5, 10);
-        int i;
-        for(i=7; i < h; i += 2)
-            p.drawLine(w, i, w + 5, i + 5);
-        for(i = w - i + h; i > 6; i -= 2)
-            p.drawLine(i, h, i + 5, h + 5);
-        for(; i > 0 ; i -= 2)
-            p.drawLine(6, h + 6 - i, i + 5, h + 5);
-    }
+
+    // draw shadow
+    p.setPen(palette().shadow().color());
+    p.drawPoint(w + 5, 6);
+    p.drawLine(w + 3, 6, w + 5, 8);
+    p.drawLine(w + 1, 6, w + 5, 10);
+    int i;
+    for(i=7; i < h; i += 2)
+        p.drawLine(w, i, w + 5, i + 5);
+    for(i = w - i + h; i > 6; i -= 2)
+        p.drawLine(i, h, i + 5, h + 5);
+    for(; i > 0 ; i -= 2)
+        p.drawLine(6, h + 6 - i, i + 5, h + 5);
+
     r.adjust(0, 0, 1, 1);
     p.setPen(palette().toolTipText().color());
     r.adjust(hMargin, vMargin, -hMargin, -vMargin);
index 64e2f9a..021257b 100644 (file)
@@ -1327,8 +1327,6 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
         d->topData()->backingStore.create(this);
     }
 
-    d->setModal_sys();
-
     if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
         setAttribute(Qt::WA_DropSiteRegistered, true);
 
@@ -1370,9 +1368,6 @@ QWidget::~QWidget()
         ungrabGesture(type);
 #endif
 
-    // force acceptDrops false before winId is destroyed.
-    d->registerDropSite(false);
-
 #ifndef QT_NO_ACTION
     // remove all actions from this widget
     for (int i = 0; i < d->actions.size(); ++i) {
@@ -1601,7 +1596,6 @@ void QWidgetPrivate::deleteExtra()
 #ifndef QT_NO_CURSOR
         delete extra->curs;
 #endif
-        deleteSysExtra();
 #ifndef QT_NO_STYLE_STYLESHEET
         // dereference the stylesheet style
         if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
@@ -2629,7 +2623,6 @@ Qt::WindowModality QWidget::windowModality() const
 void QWidget::setWindowModality(Qt::WindowModality windowModality)
 {
     data->window_modality = windowModality;
-    // setModal_sys() will be called by setAttribute()
     setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal));
     setAttribute(Qt::WA_SetWindowModality, true);
 }
@@ -9912,7 +9905,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
         break;
     }
     case Qt::WA_DropSiteRegistered:  {
-        d->registerDropSite(on);
         for (int i = 0; i < d->children.size(); ++i) {
             QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
             if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
@@ -9993,10 +9985,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
             // QApplicationPrivate::enterModal(this) here. The window must be
             // hidden before changing modality.
         }
-        if (testAttribute(Qt::WA_WState_Created)) {
-            // don't call setModal_sys() before create_sys()
-            d->setModal_sys();
-        }
         break;
     case Qt::WA_MouseTracking: {
         QEvent e(QEvent::MouseTrackingChange);
index 30351e8..fbb101b 100644 (file)
@@ -289,7 +289,6 @@ public:
     void createExtra();
     void deleteExtra();
     void createSysExtra();
-    void deleteSysExtra();
     void createTLSysExtra();
     void deleteTLSysExtra();
     void updateSystemBackground();
@@ -412,7 +411,6 @@ public:
     void _q_showIfNotHidden();
 
     void setEnabled_helper(bool);
-    void registerDropSite(bool);
     static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
 
     void updateFrameStrut();
@@ -466,8 +464,6 @@ public:
         return w;
     }
 
-    void setModal_sys();
-
     // This is an helper function that return the available geometry for
     // a widget and takes care is this one is in QGraphicsView.
     // If the widget is not embed in a scene then the geometry available is
index b306f57..b313f99 100644 (file)
@@ -420,18 +420,6 @@ void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0)
                false, (SubstructureNotifyMask | SubstructureRedirectMask), &e);
 }
 
-struct QX11WindowAttributes {
-    const XWindowAttributes *att;
-};
-
-void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const XWindowAttributes &a)
-{
-    QX11WindowAttributes att;
-    att.att = &a;
-    qt_x11_getX11InfoForWindow(xinfo,att);
-}
-
-
 static QVector<Atom> getNetWmState(QWidget *w)
 {
     QVector<Atom> returnValue;
@@ -589,7 +577,25 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
         else
             q->setAttribute(Qt::WA_WState_Visible);
 
-        qt_x11_getX11InfoForWindow(&xinfo,a);
+        QX11InfoData* xd = xinfo.getX11Data(true);
+        // find which screen the window is on...
+        xd->screen = QX11Info::appScreen(); // by default, use the default :)
+        int i;
+        for (i = 0; i < ScreenCount(X11->display); i++) {
+            if (RootWindow(X11->display, i) == a.root) {
+                xd->screen = i;
+                break;
+            }
+        }
+
+        xd->depth = a.depth;
+        xd->cells = DisplayCells(X11->display, xd->screen);
+        xd->visual = a.visual;
+        xd->defaultVisual = (XVisualIDFromVisual((Visual *) a.visual) ==
+                            XVisualIDFromVisual((Visual *) QX11Info::appVisual(scr)));
+        xd->colormap = a.colormap;
+        xd->defaultColormap = (a.colormap == QX11Info::appColormap(scr));
+        xinfo.setX11Data(xd);
 
     } else if (desktop) {                        // desktop widget
 #ifdef QWIDGET_EXTRA_DEBUG
@@ -2838,10 +2844,6 @@ void QWidgetPrivate::createSysExtra()
     extra->xDndProxy = 0;
 }
 
-void QWidgetPrivate::deleteSysExtra()
-{
-}
-
 void QWidgetPrivate::createTLSysExtra()
 {
     extra->topextra->spont_unmapped = 0;
@@ -2870,11 +2872,6 @@ void QWidgetPrivate::deleteTLSysExtra()
 #endif
 }
 
-void QWidgetPrivate::registerDropSite(bool on)
-{
-    Q_UNUSED(on);
-}
-
 void QWidgetPrivate::setMask_sys(const QRegion &region)
 {
     Q_Q(QWidget);
@@ -3087,34 +3084,6 @@ Picture QX11Data::getSolidFill(int screen, const QColor &c)
 }
 #endif
 
-void QWidgetPrivate::setModal_sys()
-{
-}
-
-void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &att)
-{
-    QX11InfoData* xd = xinfo->getX11Data(true);
-    const XWindowAttributes &a = *(att.att);
-    // find which screen the window is on...
-    xd->screen = QX11Info::appScreen(); // by default, use the default :)
-    int i;
-    for (i = 0; i < ScreenCount(X11->display); i++) {
-        if (RootWindow(X11->display, i) == a.root) {
-            xd->screen = i;
-            break;
-        }
-    }
-
-    xd->depth = a.depth;
-    xd->cells = DisplayCells(X11->display, xd->screen);
-    xd->visual = a.visual;
-    xd->defaultVisual = (XVisualIDFromVisual((Visual *) a.visual) ==
-                         XVisualIDFromVisual((Visual *) QX11Info::appVisual(xinfo->screen())));
-    xd->colormap = a.colormap;
-    xd->defaultColormap = (a.colormap == QX11Info::appColormap(xinfo->screen()));
-    xinfo->setX11Data(xd);
-}
-
 void QWidgetPrivate::updateX11AcceptFocus()
 {
     Q_Q(QWidget);
index bee557a..ae78560 100644 (file)
 #include <QtCore/qobjectdefs.h>
 #include <QtCore/qnamespace.h>
 
+// Window system dependent definitions
+
+#if defined(Q_WS_X11)
+
+typedef struct _XDisplay Display;
+typedef union  _XEvent XEvent;
+typedef struct _XGC *GC;
+typedef struct _XRegion *Region;
+typedef unsigned long  WId;
+
+#endif // Q_WS_X11
+
 QT_BEGIN_HEADER
 QT_BEGIN_NAMESPACE
 
-
 // Class forward definitions
 
 class QPaintDevice;
@@ -85,24 +96,6 @@ class QApplication;
 template<typename T> class QList;
 typedef QList<QWidget *> QWidgetList;
 
-QT_END_NAMESPACE
-QT_END_HEADER
-
-// Window system dependent definitions
-
-#if defined(Q_WS_X11)
-
-typedef struct _XDisplay Display;
-typedef union  _XEvent XEvent;
-typedef struct _XGC *GC;
-typedef struct _XRegion *Region;
-typedef unsigned long  WId;
-
-#endif // Q_WS_X11
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
 template<class K, class V> class QHash;
 typedef QHash<WId, QWidget *> QWidgetMapper;
 
@@ -112,10 +105,4 @@ typedef QSet<QWidget *> QWidgetSet;
 QT_END_NAMESPACE
 QT_END_HEADER
 
-#if defined(QT_NEEDS_QMAIN)
-#define main qMain
-#endif
-
-// Global platform-independent types and functions
-
 #endif // QWINDOWDEFS_H
index 534f392..b6e87d7 100644 (file)
@@ -56,9 +56,7 @@ class QX11Info;
 class QPaintDevice;
 class QApplicationPrivate;
 class QX11InfoPrivate;
-struct QX11WindowAttributes;
 
-void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &a);
 class Q_GUI_EXPORT QX11Info
 {
 public:
@@ -112,7 +110,6 @@ protected:
     friend void qt_init(QApplicationPrivate *priv, int, Display *display, Qt::HANDLE visual,
                         Qt::HANDLE colormap);
     friend void qt_cleanup();
-    friend void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const QX11WindowAttributes &a);
 };
 
 QT_END_NAMESPACE
index dfeecca..f8c7160 100644 (file)
@@ -1214,7 +1214,6 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event)
         return;
     }
     QWidget::timerEvent(event);
-    return;
 }
 
 /*!
index 9dd1657..c5dedce 100644 (file)
@@ -942,7 +942,6 @@ public slots:
     void titleBarDoubleClicked();
 
 protected:
-    void enterEvent(QEvent *);
     void leaveEvent(QEvent *);
     void childEvent(QChildEvent*);
     void resizeEvent(QResizeEvent *);
@@ -2826,10 +2825,6 @@ void QWorkspaceChild::doMove()
     widgetResizeHandler->doMove();
 }
 
-void QWorkspaceChild::enterEvent(QEvent *)
-{
-}
-
 void QWorkspaceChild::leaveEvent(QEvent *)
 {
 #ifndef QT_NO_CURSOR