Fix reply from notifications (Qt 5.6.2 broke it).

Now the mouse press on Qt::BypassWindowManagerHint window
doesn't activate it. So if you want a working input field
in a Qt::BypassWindowManagerHint window, you should
activate it yourself from any mouse press event.
This commit is contained in:
John Preston 2016-10-19 16:31:18 +03:00
parent 3503be03c9
commit 2ffc0196dd
4 changed files with 28 additions and 9 deletions

View File

@ -1185,14 +1185,7 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) {
_from = _user;
}
_photo->download();
updateControls();
if (isHidden()) {
psUpdateOverlayed(this);
show();
psShowOverAll(this);
activateWindow();
setFocus();
}
displayFinished();
}
void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty messages shown as docs: doc can be NULL
@ -1330,6 +1323,10 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty
_from = _user;
}
_full = 1;
displayFinished();
}
void MediaView::displayFinished() {
updateControls();
if (isHidden()) {
psUpdateOverlayed(this);

View File

@ -132,6 +132,7 @@ private slots:
private:
void displayPhoto(PhotoData *photo, HistoryItem *item);
void displayDocument(DocumentData *doc, HistoryItem *item);
void displayFinished();
void findCurrent();
void loadBack();

View File

@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "window/notifications_manager_default.h"
#include "platform/platform_notifications_manager.h"
#include "application.h"
#include "mainwindow.h"
#include "lang.h"
#include "ui/buttons/icon_button.h"
@ -725,7 +726,12 @@ void Notification::toggleActionButtons(bool visible) {
}
void Notification::showReplyField() {
if (_replyArea) return;
activateWindow();
if (_replyArea) {
_replyArea->setFocus();
return;
}
stopHiding();
_background = new Background(this);
@ -739,6 +745,9 @@ void Notification::showReplyField() {
_replyArea->setFocus();
_replyArea->setMaxLength(MaxMessageSize);
_replyArea->setCtrlEnterSubmit(CtrlEnterSubmitBoth);
// Catch mouse press event to activate the window.
Sandbox::installEventFilter(this);
connect(_replyArea, SIGNAL(resized()), this, SLOT(onReplyResize()));
connect(_replyArea, SIGNAL(submitted(bool)), this, SLOT(onReplySubmit(bool)));
connect(_replyArea, SIGNAL(cancelled()), this, SLOT(onReplyCancel()));
@ -820,6 +829,17 @@ void Notification::mousePressEvent(QMouseEvent *e) {
}
}
bool Notification::eventFilter(QObject *o, QEvent *e) {
if (e->type() == QEvent::MouseButtonPress) {
if (auto receiver = qobject_cast<QWidget*>(o)) {
if (isAncestorOf(receiver)) {
activateWindow();
}
}
}
return false;
}
void Notification::stopHiding() {
if (!_history) return;
_hideTimer.stop();

View File

@ -208,6 +208,7 @@ protected:
void leaveEvent(QEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
bool eventFilter(QObject *o, QEvent *e) override;
private slots:
void onHideByTimer();