mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Build fixed for Linux, checking for compositing manager running.
Backported QX11Info::isCompositingManagerRunning from Qt 5.7.
This commit is contained in:
parent
27ff8d4bf5
commit
bd2be4e0c1
Telegram
Patches
SourceFiles
@ -11896,6 +11896,52 @@ index 6fffa1e..cb1c9c1 100644
|
||||
void destroyWindow();
|
||||
inline bool isDropSiteEnabled() const { return m_dropTarget != 0; }
|
||||
void setDropSiteEnabled(bool enabled);
|
||||
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
||||
index 09e7ecf..c0f15a4 100644
|
||||
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
||||
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
|
||||
@@ -79,7 +79,10 @@ static int resourceType(const QByteArray &key)
|
||||
QByteArrayLiteral("rootwindow"),
|
||||
QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingenabled"),
|
||||
QByteArrayLiteral("nofonthinting"),
|
||||
- QByteArrayLiteral("atspibus")
|
||||
+ QByteArrayLiteral("atspibus"),
|
||||
+
|
||||
+ // Patch: Backport compositing manager check from Qt 5.7
|
||||
+ QByteArrayLiteral("compositingenabled")
|
||||
};
|
||||
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
|
||||
const QByteArray *result = std::find(names, end, key);
|
||||
@@ -252,6 +255,13 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
|
||||
case RootWindow:
|
||||
result = reinterpret_cast<void *>(xcbScreen->root());
|
||||
break;
|
||||
+
|
||||
+ // Patch: Backport compositing manager check from Qt 5.7
|
||||
+ case CompositingEnabled:
|
||||
+ if (QXcbVirtualDesktop *vd = xcbScreen->virtualDesktop())
|
||||
+ result = vd->compositingActive() ? this : Q_NULLPTR;
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
break;
|
||||
}
|
||||
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
|
||||
index f88b710..6f818a5 100644
|
||||
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
|
||||
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
|
||||
@@ -68,7 +68,10 @@ public:
|
||||
ScreenSubpixelType,
|
||||
ScreenAntialiasingEnabled,
|
||||
NoFontHinting,
|
||||
- AtspiBus
|
||||
+ AtspiBus,
|
||||
+
|
||||
+ // Patch: Backport compositing manager check from Qt 5.7
|
||||
+ CompositingEnabled
|
||||
};
|
||||
|
||||
QXcbNativeInterface();
|
||||
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
|
||||
index bc2de89..aa8f8df 100644
|
||||
--- a/src/widgets/dialogs/qfiledialog.cpp
|
||||
|
@ -61,7 +61,7 @@ void _trayIconActivate(GtkStatusIcon *status_icon, gpointer popup_menu) {
|
||||
|
||||
gboolean _trayIconResized(GtkStatusIcon *status_icon, gint size, gpointer popup_menu) {
|
||||
_trayIconSize = size;
|
||||
if (App::wnd()) App::wnd()->psUpdateCounter();
|
||||
if (Global::started()) Notify::unreadCounterUpdated();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ static gboolean _trayIconCheck(gpointer/* pIn*/) {
|
||||
cSetSupportTray(true);
|
||||
if (App::wnd()) {
|
||||
App::wnd()->psUpdateWorkmode();
|
||||
App::wnd()->psUpdateCounter();
|
||||
Notify::unreadCounterUpdated();
|
||||
App::wnd()->updateTrayMenu();
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ void MainWindow::psTrayMenuUpdated() {
|
||||
void MainWindow::psSetupTrayIcon() {
|
||||
if (noQtTrayIcon) {
|
||||
if (!cSupportTray()) return;
|
||||
psUpdateCounter();
|
||||
updateIconCounters();
|
||||
} else {
|
||||
LOG(("Using Qt tray icon."));
|
||||
if (!trayIcon) {
|
||||
@ -266,7 +266,7 @@ void MainWindow::psSetupTrayIcon() {
|
||||
|
||||
App::wnd()->updateTrayMenu();
|
||||
}
|
||||
psUpdateCounter();
|
||||
updateIconCounters();
|
||||
|
||||
trayIcon->show();
|
||||
}
|
||||
@ -315,12 +315,16 @@ void MainWindow::psUpdateIndicator() {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::psUpdateCounter() {
|
||||
void MainWindow::unreadCounterChangedHook() {
|
||||
setWindowTitle(titleText());
|
||||
updateIconCounters();
|
||||
}
|
||||
|
||||
void MainWindow::updateIconCounters() {
|
||||
setWindowIcon(wndIcon);
|
||||
|
||||
int32 counter = App::histories().unreadBadge();
|
||||
|
||||
setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
if (_psUnityLauncherEntry) {
|
||||
if (counter > 0) {
|
||||
|
@ -74,6 +74,7 @@ protected:
|
||||
virtual void placeSmallCounter(QImage &img, int size, int count, const style::color &bg, const QPoint &shift, const style::color &color) = 0;
|
||||
|
||||
private:
|
||||
void updateIconCounters();
|
||||
void psCreateTrayIcon();
|
||||
|
||||
QTimer _psCheckStatusIconTimer;
|
||||
@ -81,6 +82,7 @@ private:
|
||||
|
||||
QTimer _psUpdateIndicatorTimer;
|
||||
uint64 _psLastIndicatorUpdate = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Platform
|
||||
|
@ -36,6 +36,7 @@ void start();
|
||||
void finish();
|
||||
|
||||
void SetWatchingMediaKeys(bool watching);
|
||||
bool TransparentWindowsSupported(QPoint globalPosition);
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
|
@ -34,6 +34,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
using namespace Platform;
|
||||
|
||||
namespace {
|
||||
@ -409,6 +411,31 @@ void finish() {
|
||||
void SetWatchingMediaKeys(bool watching) {
|
||||
}
|
||||
|
||||
bool TransparentWindowsSupported(QPoint globalPosition) {
|
||||
if (auto app = static_cast<QGuiApplication*>(QCoreApplication::instance())) {
|
||||
if (auto native = app->platformNativeInterface()) {
|
||||
if (auto desktop = QApplication::desktop()) {
|
||||
auto index = desktop->screenNumber(globalPosition);
|
||||
auto screens = QGuiApplication::screens();
|
||||
if (auto screen = (index >= 0 && index < screens.size()) ? screens[index] : QGuiApplication::primaryScreen()) {
|
||||
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static OrderedSet<int> WarnedAbout;
|
||||
if (!WarnedAbout.contains(index)) {
|
||||
WarnedAbout.insert(index);
|
||||
LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
|
||||
}
|
||||
} else {
|
||||
LOG(("WARNING: Could not get screen for index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
|
@ -405,6 +405,10 @@ void finish() {
|
||||
objc_finish();
|
||||
}
|
||||
|
||||
bool TransparentWindowsSupported(QPoint globalPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
|
@ -732,6 +732,10 @@ void finish() {
|
||||
void SetWatchingMediaKeys(bool watching) {
|
||||
}
|
||||
|
||||
bool TransparentWindowsSupported(QPoint globalPosition) {
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
|
@ -68,7 +68,7 @@ void PopupMenu::init() {
|
||||
}
|
||||
|
||||
void PopupMenu::handleCompositingUpdate() {
|
||||
_padding = _compositing ? _st.shadow.extend : style::margins(st::lineWidth, st::lineWidth, st::lineWidth, st::lineWidth);
|
||||
_padding = _useTransaprency ? _st.shadow.extend : style::margins(st::lineWidth, st::lineWidth, st::lineWidth, st::lineWidth);
|
||||
_menu->moveToLeft(_padding.left() + _st.scrollPadding.left(), _padding.top() + _st.scrollPadding.top());
|
||||
handleMenuResize();
|
||||
}
|
||||
@ -126,7 +126,7 @@ void PopupMenu::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
void PopupMenu::paintBg(Painter &p) {
|
||||
if (_compositing) {
|
||||
if (_useTransaprency) {
|
||||
Shadow::paint(p, _inner, width(), _st.shadow);
|
||||
App::roundRect(p, _inner, _st.menu.itemBg, ImageRoundRadius::Small);
|
||||
} else {
|
||||
@ -307,7 +307,7 @@ void PopupMenu::prepareCache() {
|
||||
|
||||
void PopupMenu::startOpacityAnimation(bool hiding) {
|
||||
_hiding = false;
|
||||
if (!_compositing) {
|
||||
if (!_useTransaprency) {
|
||||
_a_opacity.finish();
|
||||
if (hiding) {
|
||||
hideFinished();
|
||||
@ -334,7 +334,7 @@ void PopupMenu::showStarted() {
|
||||
}
|
||||
|
||||
void PopupMenu::startShowAnimation() {
|
||||
if (!_compositing) {
|
||||
if (!_useTransaprency) {
|
||||
_a_show.finish();
|
||||
update();
|
||||
return;
|
||||
@ -347,7 +347,7 @@ void PopupMenu::startShowAnimation() {
|
||||
|
||||
_showAnimation = std_::make_unique<PanelAnimation>(_st.animation, _origin);
|
||||
_showAnimation->setFinalImage(std_::move(cache), _inner);
|
||||
if (_compositing) {
|
||||
if (_useTransaprency) {
|
||||
auto corners = App::cornersMask(ImageRoundRadius::Small);
|
||||
_showAnimation->setCornerMasks(QImage(*corners[0]), QImage(*corners[1]), QImage(*corners[2]), QImage(*corners[3]));
|
||||
} else {
|
||||
@ -382,7 +382,7 @@ QImage PopupMenu::grabForPanelAnimation() {
|
||||
result.fill(Qt::transparent);
|
||||
{
|
||||
Painter p(&result);
|
||||
if (_compositing) {
|
||||
if (_useTransaprency) {
|
||||
App::roundRect(p, _inner, _st.menu.itemBg, ImageRoundRadius::Small);
|
||||
} else {
|
||||
p.fillRect(_inner, _st.menu.itemBg);
|
||||
@ -410,11 +410,7 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
||||
auto origin = PanelAnimation::Origin::TopLeft;
|
||||
auto w = p - QPoint(0, _padding.top());
|
||||
auto r = Sandbox::screenGeometry(p);
|
||||
#ifdef Q_OS_LINUX
|
||||
_compositing = QX11Info::isCompositingManagerRunning(QApplication::desktop()->screenNumber(p));
|
||||
#else // Q_OS_LINUX
|
||||
_compositing = true;
|
||||
#endif // Q_OS_LINUX
|
||||
_useTransaprency = Platform::TransparentWindowsSupported(p);
|
||||
handleCompositingUpdate();
|
||||
if (rtl()) {
|
||||
if (w.x() - width() < r.x() - _padding.left()) {
|
||||
|
@ -117,7 +117,7 @@ private:
|
||||
std_::unique_ptr<PanelAnimation> _showAnimation;
|
||||
FloatAnimation _a_show;
|
||||
|
||||
bool _compositing = true;
|
||||
bool _useTransaprency = true;
|
||||
bool _hiding = false;
|
||||
QPixmap _cache;
|
||||
FloatAnimation _a_opacity;
|
||||
|
Loading…
Reference in New Issue
Block a user