mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Subscribe to QEvent::WindowStateChange instead of QWindow::windowStateChanged
This commit is contained in:
parent
f768e405fa
commit
fc5e9414b7
3 changed files with 21 additions and 40 deletions
|
@ -383,20 +383,14 @@ void Panel::initWindow() {
|
||||||
&& _fullScreenOrMaximized.current()) {
|
&& _fullScreenOrMaximized.current()) {
|
||||||
toggleFullScreen();
|
toggleFullScreen();
|
||||||
}
|
}
|
||||||
|
} else if (e->type() == QEvent::WindowStateChange && _call->rtmp()) {
|
||||||
|
const auto state = window()->windowState();
|
||||||
|
_fullScreenOrMaximized = (state & Qt::WindowFullScreen)
|
||||||
|
|| (state & Qt::WindowMaximized);
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_call->rtmp()) {
|
|
||||||
QObject::connect(
|
|
||||||
window()->windowHandle(),
|
|
||||||
&QWindow::windowStateChanged,
|
|
||||||
[=](Qt::WindowState state) {
|
|
||||||
_fullScreenOrMaximized = (state == Qt::WindowFullScreen)
|
|
||||||
|| (state == Qt::WindowMaximized);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
window()->setBodyTitleArea([=](QPoint widgetPoint) {
|
window()->setBodyTitleArea([=](QPoint widgetPoint) {
|
||||||
using Flag = Ui::WindowTitleHitTestFlag;
|
using Flag = Ui::WindowTitleHitTestFlag;
|
||||||
const auto titleRect = QRect(
|
const auto titleRect = QRect(
|
||||||
|
|
|
@ -504,6 +504,22 @@ OverlayWidget::OverlayWidget()
|
||||||
if (handleContextMenu(position)) {
|
if (handleContextMenu(position)) {
|
||||||
return base::EventFilterResult::Cancel;
|
return base::EventFilterResult::Cancel;
|
||||||
}
|
}
|
||||||
|
} else if (e->type() == QEvent::WindowStateChange) {
|
||||||
|
const auto state = _window->windowState();
|
||||||
|
if (state & Qt::WindowMinimized || Platform::IsMac()) {
|
||||||
|
} else if (state & Qt::WindowMaximized) {
|
||||||
|
if (_fullscreen || _windowed) {
|
||||||
|
_fullscreen = _windowed = false;
|
||||||
|
savePosition();
|
||||||
|
}
|
||||||
|
} else if (_fullscreen || _windowed) {
|
||||||
|
} else if (state & Qt::WindowFullScreen) {
|
||||||
|
_fullscreen = true;
|
||||||
|
savePosition();
|
||||||
|
} else {
|
||||||
|
_windowed = true;
|
||||||
|
savePosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
});
|
});
|
||||||
|
@ -733,29 +749,6 @@ void OverlayWidget::setupWindow() {
|
||||||
return Flag::Move | Flag(0);
|
return Flag::Move | Flag(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto callback = [=](Qt::WindowState state) {
|
|
||||||
if (state == Qt::WindowMinimized || Platform::IsMac()) {
|
|
||||||
return;
|
|
||||||
} else if (state == Qt::WindowMaximized) {
|
|
||||||
if (_fullscreen || _windowed) {
|
|
||||||
_fullscreen = _windowed = false;
|
|
||||||
savePosition();
|
|
||||||
}
|
|
||||||
} else if (_fullscreen || _windowed) {
|
|
||||||
return;
|
|
||||||
} else if (state == Qt::WindowFullScreen) {
|
|
||||||
_fullscreen = true;
|
|
||||||
savePosition();
|
|
||||||
} else {
|
|
||||||
_windowed = true;
|
|
||||||
savePosition();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
QObject::connect(
|
|
||||||
_window->windowHandle(),
|
|
||||||
&QWindow::windowStateChanged,
|
|
||||||
callback);
|
|
||||||
|
|
||||||
_window->setAttribute(Qt::WA_NoSystemBackground, true);
|
_window->setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
_window->setAttribute(Qt::WA_TranslucentBackground, true);
|
_window->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
|
||||||
|
@ -3246,7 +3239,7 @@ bool OverlayWidget::isHidden() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayWidget::isMinimized() const {
|
bool OverlayWidget::isMinimized() const {
|
||||||
return _window->windowHandle()->windowState() == Qt::WindowMinimized;
|
return _window->isMinimized();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayWidget::isFullScreen() const {
|
bool OverlayWidget::isFullScreen() const {
|
||||||
|
|
|
@ -459,12 +459,6 @@ void MainWindow::init() {
|
||||||
|
|
||||||
initHook();
|
initHook();
|
||||||
|
|
||||||
connect(
|
|
||||||
windowHandle(),
|
|
||||||
&QWindow::windowStateChanged,
|
|
||||||
this,
|
|
||||||
[=](Qt::WindowState state) { handleStateChanged(state); });
|
|
||||||
|
|
||||||
updatePalette();
|
updatePalette();
|
||||||
|
|
||||||
if (Ui::Platform::NativeWindowFrameSupported()) {
|
if (Ui::Platform::NativeWindowFrameSupported()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue