From 12c20faa441b88254dabf4bd15de4dfb9ab7d110 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 22 Jun 2016 22:50:44 +0300 Subject: [PATCH 1/3] Fixed Linux build. Alpha version 0.9.54. --- .../platform/linux/main_window_linux.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 4ad63d0bf..dfc4b7462 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -249,9 +249,9 @@ void MainWindow::psSetupTrayIcon() { trayIcon = new QSystemTrayIcon(this); QIcon icon; - QFileInfo f(_trayIconImageFile()); - if (f.exists()) { - QByteArray path = QFile::encodeName(f.absoluteFilePath()); + QFileInfo iconFile(_trayIconImageFile()); + if (iconFile.exists()) { + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); icon = QIcon(path.constData()); } else { icon = QIcon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly)); @@ -303,9 +303,9 @@ void MainWindow::psUpdateWorkmode() { void MainWindow::psUpdateIndicator() { _psUpdateIndicatorTimer.stop(); _psLastIndicatorUpdate = getms(); - QFileInfo f(_trayIconImageFile()); - if (f.exists()) { - QByteArray path = QFile::encodeName(f.absoluteFilePath()), name = QFile::encodeName(f.fileName()); + QFileInfo iconFile(_trayIconImageFile()); + if (iconFile.exists()) { + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()), name = QFile::encodeName(iconFile.fileName()); name = name.mid(0, name.size() - 4); Libs::app_indicator_set_icon_full(_trayIndicator, path.constData(), name); } else { @@ -338,7 +338,7 @@ void MainWindow::psUpdateCounter() { } else if (useStatusIcon && trayIconChecked) { QFileInfo iconFile(_trayIconImageFile()); if (iconFile.exists()) { - QByteArray path = QFile::encodeName(f.absoluteFilePath()); + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); Libs::gtk_status_icon_set_from_file(_trayIcon, path.constData()); } else { loadPixbuf(_trayIconImageGen()); @@ -347,9 +347,9 @@ void MainWindow::psUpdateCounter() { } } else if (trayIcon) { QIcon icon; - QFileInfo f(_trayIconImageFile()); - if (f.exists()) { - QByteArray path = QFile::encodeName(f.absoluteFilePath()); + QFileInfo iconFile(_trayIconImageFile()); + if (iconFile.exists()) { + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); icon = QIcon(path.constData()); } else { int32 counter = App::histories().unreadBadge(); @@ -524,9 +524,9 @@ void MainWindow::psCreateTrayIcon() { _trayMenu = Libs::gtk_menu_new(); if (_trayMenu) { DEBUG_LOG(("Created gtk menu for appindicator!")); - QFileInfo f(_trayIconImageFile()); - if (f.exists()) { - QByteArray path = QFile::encodeName(f.absoluteFilePath()); + QFileInfo iconFile(_trayIconImageFile()); + if (iconFile.exists()) { + QByteArray path = QFile::encodeName(iconFile.absoluteFilePath()); _trayIndicator = Libs::app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS); if (_trayIndicator) { DEBUG_LOG(("Created appindicator!")); From 331c13ed788ef11be29a24ef7d191748a31d4988 Mon Sep 17 00:00:00 2001 From: Andy Kluger Date: Wed, 22 Jun 2016 17:42:46 -0400 Subject: [PATCH 2/3] Add TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION Signed-off-by: Andy Kluger (github: andydecleyre) --- .travis.yml | 1 + .travis/build.sh | 4 ++++ Telegram/SourceFiles/pspecific_linux.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0b1724aa0..1f5333843 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - BUILD_VERSION="disable_register_custom_scheme" - BUILD_VERSION="disable_crash_reports" - BUILD_VERSION="disable_network_proxy" + - BUILD_VERSION="disable_desktop_file_generation" arch: packages: diff --git a/.travis/build.sh b/.travis/build.sh index 8ecdfaa96..b31262833 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -79,6 +79,10 @@ prepare() { options+="\nDEFINES += TDESKTOP_DISABLE_NETWORK_PROXY" fi + if [[ $BUILD_VERSION == *"disable_desktop_file_generation"* ]]; then + options+="\nDEFINES += TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION" + fi + options+='\nINCLUDEPATH += "/usr/lib/glib-2.0/include"' options+='\nINCLUDEPATH += "/usr/lib/gtk-2.0/include"' options+='\nINCLUDEPATH += "/usr/include/opus"' diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index f5e880cac..6c4ad17a9 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -434,6 +434,7 @@ void psRegisterCustomScheme() { QString home(_psHomeDir()); if (home.isEmpty() || cBetaVersion()) return; // don't update desktop file for beta version + #ifndef TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION DEBUG_LOG(("App Info: placing .desktop file")); if (QDir(home + qsl(".local/")).exists()) { QString apps = home + qsl(".local/share/applications/"); @@ -480,6 +481,7 @@ void psRegisterCustomScheme() { LOG(("App Error: Could not open '%1' for write").arg(file)); } } + #endif // TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION DEBUG_LOG(("App Info: registerting for Gnome")); if (_psRunCommand("gconftool-2 -t string -s /desktop/gnome/url-handlers/tg/command " + escapeShell(escapeShell(QFile::encodeName(cExeDir() + cExeName())) + " -- %s"))) { From f6af535f8fbe95d475552092eda8a3b21281ea10 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 24 Jun 2016 19:43:46 +0300 Subject: [PATCH 3/3] Fixed dead keys in photo / file caption input field #1418 Another attempt to fix dead keys input problem after main window looses focus to popup menu or photo viewer #2007 #1074 --- Telegram/SourceFiles/mainwindow.cpp | 19 ++++++++++++++++--- Telegram/SourceFiles/mainwindow.h | 2 ++ Telegram/SourceFiles/ui/flatinput.cpp | 8 ++++---- Telegram/SourceFiles/ui/flatinput.h | 6 ++++++ Telegram/SourceFiles/ui/popupmenu.cpp | 5 +++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 8f7652aca..b8301929d 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -926,13 +926,26 @@ void MainWindow::layerHidden() { setInnerFocus(); } +void MainWindow::onReActivate() { + if (auto w = App::wnd()) { + if (auto f = QApplication::focusWidget()) { + f->clearFocus(); + } + w->windowHandle()->requestActivate(); + w->activate(); + if (auto f = QApplication::focusWidget()) { + f->clearFocus(); + } + w->setInnerFocus(); + } +} + void MainWindow::hideMediaview() { if (_mediaView && !_mediaView->isHidden()) { _mediaView->hide(); #if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 - if (App::wnd()) { - App::wnd()->activateWindow(); - } + onReActivate(); + QTimer::singleShot(200, this, SLOT(onReActivate())); #endif } } diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index 5a7826c61..32926621b 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -282,6 +282,8 @@ public slots: void onLogoutSure(); void updateGlobalMenu(); // for OS X top menu + void onReActivate(); + void notifyUpdateAllPhotos(); void app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button); diff --git a/Telegram/SourceFiles/ui/flatinput.cpp b/Telegram/SourceFiles/ui/flatinput.cpp index dbb8f3006..2ff1ba92f 100644 --- a/Telegram/SourceFiles/ui/flatinput.cpp +++ b/Telegram/SourceFiles/ui/flatinput.cpp @@ -765,11 +765,11 @@ void InputArea::startBorderAnimation() { } void InputArea::focusInEvent(QFocusEvent *e) { - _inner.setFocus(); + QTimer::singleShot(0, &_inner, SLOT(setFocus())); } void InputArea::mousePressEvent(QMouseEvent *e) { - _inner.setFocus(); + QTimer::singleShot(0, &_inner, SLOT(setFocus())); } void InputArea::contextMenuEvent(QContextMenuEvent *e) { @@ -1457,11 +1457,11 @@ void InputField::startBorderAnimation() { } void InputField::focusInEvent(QFocusEvent *e) { - _inner.setFocus(); + QTimer::singleShot(0, &_inner, SLOT(setFocus())); } void InputField::mousePressEvent(QMouseEvent *e) { - _inner.setFocus(); + QTimer::singleShot(0, &_inner, SLOT(setFocus())); } void InputField::contextMenuEvent(QContextMenuEvent *e) { diff --git a/Telegram/SourceFiles/ui/flatinput.h b/Telegram/SourceFiles/ui/flatinput.h index e121b0434..b200b76b2 100644 --- a/Telegram/SourceFiles/ui/flatinput.h +++ b/Telegram/SourceFiles/ui/flatinput.h @@ -235,6 +235,12 @@ public: bool hasFocus() const { return _inner.hasFocus(); } + void setFocus() { + _inner.setFocus(); + } + void clearFocus() { + _inner.clearFocus(); + } public slots: diff --git a/Telegram/SourceFiles/ui/popupmenu.cpp b/Telegram/SourceFiles/ui/popupmenu.cpp index d78746c87..2bbf65890 100644 --- a/Telegram/SourceFiles/ui/popupmenu.cpp +++ b/Telegram/SourceFiles/ui/popupmenu.cpp @@ -521,8 +521,9 @@ PopupMenu::~PopupMenu() { clearActions(true); delete _menu; #if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 - if (App::wnd()) { - App::wnd()->activateWindow(); + if (auto w = App::wnd()) { + w->onReActivate(); + QTimer::singleShot(200, w, SLOT(onReActivate())); } #endif }