summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Preston <johnprestonmail@gmail.com>2022-12-28 13:05:23 +0400
committerJohn Preston <johnprestonmail@gmail.com>2022-12-28 13:05:23 +0400
commit17f40d6a1fcd8ece9e4773280cc0de2c2e154120 (patch)
treeeafc57e73fcbbe521c5915cf033c9b03e6f0db44
parent77078f704c9ca6c8fc16850f107ffb15196381c9 (diff)
Don't lose focus when showing image editor.
-rw-r--r--Telegram/SourceFiles/editor/editor_layer_widget.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/Telegram/SourceFiles/editor/editor_layer_widget.cpp b/Telegram/SourceFiles/editor/editor_layer_widget.cpp
index daeddf2d12..6e75600f34 100644
--- a/Telegram/SourceFiles/editor/editor_layer_widget.cpp
+++ b/Telegram/SourceFiles/editor/editor_layer_widget.cpp
@@ -107,21 +107,36 @@ void LayerWidget::checkBackgroundStale() {
}
QImage LayerWidget::renderBackground() {
- const auto target = parentWidget()->parentWidget();
+ const auto parent = parentWidget();
+ const auto target = parent->parentWidget();
Ui::SendPendingMoveResizeEvents(target);
const auto ratio = style::DevicePixelRatio();
auto image = QImage(size() * ratio, QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(ratio);
- const auto shown = !parentWidget()->isHidden();
- if (shown) parentWidget()->hide();
-
+ const auto shown = !parent->isHidden();
+ const auto focused = shown && Ui::InFocusChain(parent);
+ if (shown) {
+ if (focused) {
+ target->setFocus();
+ }
+ parent->hide();
+ }
auto p = QPainter(&image);
Ui::RenderWidget(p, target, QPoint(), geometry());
p.end();
- if (shown) parentWidget()->show();
+ if (shown) {
+ parent->show();
+ if (focused) {
+ if (isHidden()) {
+ parent->setFocus();
+ } else {
+ setInnerFocus();
+ }
+ }
+ }
return image;
}