Attempt to fix window geometry restore on Windows.
This commit is contained in:
parent
00f5bdaccd
commit
aa39793a91
7 changed files with 48 additions and 1 deletions
|
|
@ -615,5 +615,11 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
|
||||||
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetGeometryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry) {
|
||||||
|
widget->setGeometry(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
|
|
@ -164,5 +164,11 @@ std::optional<bool> IsOverlapped(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetGeometryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry) {
|
||||||
|
widget->setGeometry(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point);
|
||||||
|
|
||||||
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu);
|
||||||
|
|
||||||
|
void SetGeometryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry);
|
||||||
|
|
||||||
} // namespace Ui::Platform
|
} // namespace Ui::Platform
|
||||||
|
|
||||||
// Platform dependent implementations.
|
// Platform dependent implementations.
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
#include <Shobjidl.h>
|
#include <Shobjidl.h>
|
||||||
|
|
||||||
|
#include "base/event_filter.h"
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
using namespace Microsoft::WRL;
|
using namespace Microsoft::WRL;
|
||||||
|
|
||||||
namespace Ui::Platform {
|
namespace Ui::Platform {
|
||||||
|
|
@ -177,4 +181,19 @@ void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu) {
|
||||||
menu->lifetime().make_state<Filter>(menu));
|
menu->lifetime().make_state<Filter>(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetGeometryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry) {
|
||||||
|
const auto screen = QGuiApplication::screenAt(geometry.center());
|
||||||
|
const auto window = widget->window();
|
||||||
|
window->createWinId();
|
||||||
|
const auto handle = window->windowHandle();
|
||||||
|
if (handle->screen() != screen) {
|
||||||
|
handle->setScreen(screen);
|
||||||
|
window->move(screen->availableGeometry().topLeft());
|
||||||
|
window->show();
|
||||||
|
}
|
||||||
|
widget->setGeometry(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui::Platform
|
} // namespace Ui::Platform
|
||||||
|
|
|
||||||
|
|
@ -356,7 +356,9 @@ void WindowHelper::setFixedSize(QSize size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::setGeometry(QRect rect) {
|
void WindowHelper::setGeometry(QRect rect) {
|
||||||
window()->setGeometry(rect.marginsAdded({ 0, titleHeight(), 0, 0 }));
|
SetGeometryWithPossibleScreenChange(
|
||||||
|
window(),
|
||||||
|
rect.marginsAdded({ 0, titleHeight(), 0, 0 }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::showFullScreen() {
|
void WindowHelper::showFullScreen() {
|
||||||
|
|
|
||||||
|
|
@ -252,4 +252,10 @@ QPoint MapFrom(
|
||||||
return { MapFrom(to, from, rect.topLeft()), rect.size() };
|
return { MapFrom(to, from, rect.topLeft()), rect.size() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetGeometryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry) {
|
||||||
|
Platform::SetGeometryWithPossibleScreenChange(widget, geometry);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
|
|
@ -207,4 +207,8 @@ int WheelDirection(not_null<QWheelEvent*> e);
|
||||||
not_null<QWidget*> from,
|
not_null<QWidget*> from,
|
||||||
QRect rect);
|
QRect rect);
|
||||||
|
|
||||||
|
void SetGeomtryWithPossibleScreenChange(
|
||||||
|
not_null<QWidget*> widget,
|
||||||
|
QRect geometry);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue