File indexing completed on 2024-04-28 05:47:17
0001 /***************************************************************************** 0002 * Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU Lesser General Public License as * 0006 * published by the Free Software Foundation; either version 2.1 of the * 0007 * License, or (at your option) version 3, or any later version accepted * 0008 * by the membership of KDE e.V. (or its successor approved by the * 0009 * membership of KDE e.V.), which shall act as a proxy defined in * 0010 * Section 6 of version 3 of the license. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0015 * Lesser General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU Lesser General Public * 0018 * License along with this library. If not, * 0019 * see <http://www.gnu.org/licenses/>. * 0020 *****************************************************************************/ 0021 0022 #include "config.h" 0023 #include <qtcurve-utils/qtprops.h> 0024 0025 #include "qtcurve_p.h" 0026 #include "argbhelper.h" 0027 #include <QMenu> 0028 0029 namespace QtCurve { 0030 0031 __attribute__((hot)) void 0032 Style::prePolish(QWidget *widget) const 0033 { 0034 if (!widget) 0035 return; 0036 QtcQWidgetProps props(widget); 0037 // HACK: 0038 // Request for RGBA format on toplevel widgets before they 0039 // create native windows. These windows are typically shown after being 0040 // created before entering the main loop and therefore do not have a 0041 // chance to be polished before creating window id. (NOTE: somehow the popup 0042 // menu on mdi sub window in QtDesigner has the same problem). 0043 // TODO: 0044 // Use all information to check if a widget should be transparent. 0045 // Need to figure out how Qt5's xcb backend deal with RGB native window 0046 // as a child of a RGBA window. However, since Qt5 will not recreate 0047 // native window, this is probably easier to deal with than Qt4. 0048 // (After we create a RGB window, Qt5 will not override it). 0049 if (!(widget->windowFlags() & Qt::MSWindowsOwnDC) && 0050 !qtcGetWid(widget) && !props->prePolishing) { 0051 // Skip MSWindowsOwnDC since it is set for QGLWidget and not likely to 0052 // be used in other cases. 0053 if ((opts.bgndOpacity != 100 && (qtcIsWindow(widget) || 0054 qtcIsToolTip(widget))) || 0055 (opts.dlgOpacity != 100 && qtcIsDialog(widget)) || 0056 (opts.menuBgndOpacity != 100 && 0057 (qobject_cast<QMenu*>(widget) || 0058 widget->inherits("QComboBoxPrivateContainer")))) { 0059 props->prePolishing = true; 0060 addAlphaChannel(widget); 0061 // QWidgetPrivate::updateIsTranslucent sets the format back 0062 // is Qt::WA_TranslucentBackground is not set. So we need to do 0063 // this repeatedly 0064 props->prePolishing = false; 0065 } 0066 } 0067 } 0068 }