Toggle fullscreen by double click.

This commit is contained in:
John Preston 2020-08-12 20:58:24 +04:00
parent 537645c282
commit c93d3ae924
5 changed files with 92 additions and 24 deletions

View File

@ -268,59 +268,65 @@ callTitle: WindowTitle(defaultWindowTitle) {
fgActive: transparent;
minimize: IconButton(windowTitleButton) {
icon: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_minimize", callStatusFg, point(4px, 4px) },
};
iconOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_minimize", callStatusFg, point(4px, 4px) },
};
}
minimizeIconActive: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_minimize", callStatusFg, point(4px, 4px) },
};
minimizeIconActiveOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_minimize", callStatusFg, point(4px, 4px) },
};
maximize: IconButton(windowTitleButton) {
icon: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_maximize", callStatusFg, point(4px, 4px) },
};
iconOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_maximize", callStatusFg, point(4px, 4px) },
};
}
maximizeIconActive: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_maximize", callStatusFg, point(4px, 4px) },
};
maximizeIconActiveOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_maximize", callStatusFg, point(4px, 4px) },
};
restoreIcon: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_restore", callStatusFg, point(4px, 4px) },
};
restoreIconOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_restore", callStatusFg, point(4px, 4px) },
};
restoreIconActive: icon {
{ size(24px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_restore", callStatusFg, point(4px, 4px) },
};
restoreIconActiveOver: icon {
{ size(24px, 21px), callBgButton },
{ size(24px, 21px), callMuteRipple },
{ "title_button_restore", callStatusFg, point(4px, 4px) },
};
close: IconButton(windowTitleButtonClose) {
icon: icon {
{ size(25px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_close", callStatusFg, point(5px, 4px) },
};
iconOver: icon {
@ -329,7 +335,7 @@ callTitle: WindowTitle(defaultWindowTitle) {
};
}
closeIconActive: icon {
{ size(25px, 21px), callBgOpaque },
{ size(24px, 21px), callBgButton },
{ "title_button_close", callStatusFg, point(5px, 4px) },
};
closeIconActiveOver: icon {

View File

@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication>
#include <QtGui/QWindow>
namespace Calls {
namespace {
@ -296,25 +297,59 @@ void Panel::initWindow() {
_window->setWindowIcon(
QIcon(QPixmap::fromImage(Image::Empty()->original(), Qt::ColorOnly)));
_window->setTitle(u" "_q);
_window->setTitleStyle(st::callTitle);
_window->events(
) | rpl::start_with_next([=](not_null<QEvent*> e) {
if (e->type() == QEvent::Close) {
handleClose();
} else if (e->type() == QEvent::KeyPress) {
if ((static_cast<QKeyEvent*>(e.get())->key() == Qt::Key_Escape)
&& _window->isFullScreen()) {
_window->showNormal();
}
}
}, _window->lifetime());
_window->setBodyTitleArea([=](QPoint widgetPoint) {
const auto buttonWidth = st::callCancel.button.width;
const auto buttonsWidth = buttonWidth * 4;
return !_fingerprintArea.contains(widgetPoint)
&& !QRect(
const auto inControls = _fingerprintArea.contains(widgetPoint)
|| QRect(
(widget()->width() - buttonsWidth) / 2,
_answerHangupRedial->y(),
buttonsWidth,
_answerHangupRedial->height()).contains(widgetPoint)
&& !_outgoingVideoBubble->geometry().contains(widgetPoint);
|| (!_outgoingPreviewInBody
&& _outgoingVideoBubble->geometry().contains(widgetPoint));
using Flag = Ui::WindowTitleHitTestFlag;
return inControls
? Flag::None
: (Flag::Move | Flag::FullScreen);
});
#ifdef Q_OS_WIN
// On Windows we replace snap-to-top maximizing with fullscreen.
//
// We have to switch first to showNormal, so that showFullScreen
// will remember correct normal window geometry and next showNormal
// will show it instead of a moving maximized window.
//
// We have to do it in InvokeQueued, otherwise it still captures
// the maximized window geometry and saves it.
//
// I couldn't find a less glitchy way to do that *sigh*.
const auto object = _window->windowHandle();
const auto signal = &QWindow::windowStateChanged;
QObject::connect(object, signal, [=](Qt::WindowState state) {
if (state == Qt::WindowMaximized) {
InvokeQueued(object, [=] {
_window->showNormal();
_window->showFullScreen();
});
}
});
#endif // Q_OS_WIN
}
void Panel::initWidget() {
@ -444,7 +479,9 @@ void Panel::reinitWithCall(Call *call) {
stateChanged(state);
}, _callLifetime);
_call->videoIncoming()->renderNextFrame(
rpl::merge(
_call->videoIncoming()->renderNextFrame(),
_call->videoOutgoing()->renderNextFrame()
) | rpl::start_with_next([=] {
setIncomingShown(!_call->videoIncoming()->frame({}).isNull());
widget()->update();
@ -503,7 +540,6 @@ void Panel::initGeometry() {
const auto initRect = QRect(0, 0, st::callWidth, st::callHeight);
_window->setGeometry(initRect.translated(center - initRect.center()));
_window->setMinimumSize({ st::callWidthMin, st::callHeightMin });
_window->setTitleStyle(st::callTitle);
_window->show();
updateControlsGeometry();
}

View File

@ -45,7 +45,11 @@ void VideoBubble::setup() {
_track->markFrameShown();
} else {
updateVisibility();
_content.update();
// We update whole parent widget in this case.
// In case we update only bubble without the parent incoming
// video frame we may get full parent of old frame with a
// rectangular piece of a new frame rendered with that update().
//_content.update();
}
}, lifetime());
}

View File

@ -53,15 +53,15 @@ if (NOT DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION)
platform/PlatformInterface.h
# Teleram Desktop
platform/tdesktop/DesktopInterface.cpp
platform/tdesktop/DesktopInterface.h
platform/tdesktop/VideoCapturerInterfaceImpl.cpp
platform/tdesktop/VideoCapturerInterfaceImpl.h
platform/tdesktop/VideoCapturerTrackSource.cpp
platform/tdesktop/VideoCapturerTrackSource.h
platform/tdesktop/VideoCameraCapturer.cpp
platform/tdesktop/VideoCameraCapturer.h
# Android
platform/android/AndroidContext.cpp
platform/android/AndroidContext.h
platform/android/AndroidInterface.cpp
platform/android/AndroidInterface.h
platform/android/VideoCameraCapturer.cpp
platform/android/VideoCameraCapturer.h
platform/android/VideoCapturerInterfaceImpl.cpp
platform/android/VideoCapturerInterfaceImpl.h
# iOS / macOS
platform/darwin/DarwinInterface.h
@ -95,6 +95,17 @@ if (NOT DESKTOP_APP_DISABLE_WEBRTC_INTEGRATION)
# POSIX
# Teleram Desktop
platform/tdesktop/DesktopInterface.cpp
platform/tdesktop/DesktopInterface.h
platform/tdesktop/VideoCapturerInterfaceImpl.cpp
platform/tdesktop/VideoCapturerInterfaceImpl.h
platform/tdesktop/VideoCapturerTrackSource.cpp
platform/tdesktop/VideoCapturerTrackSource.h
platform/tdesktop/VideoCameraCapturer.cpp
platform/tdesktop/VideoCameraCapturer.h
# All
reference/InstanceImplReference.cpp
reference/InstanceImplReference.h
)
@ -150,6 +161,17 @@ else()
)
endif()
remove_target_sources(lib_tgcalls ${tgcalls_loc}
platform/android/AndroidContext.cpp
platform/android/AndroidContext.h
platform/android/AndroidInterface.cpp
platform/android/AndroidInterface.h
platform/android/VideoCameraCapturer.cpp
platform/android/VideoCameraCapturer.h
platform/android/VideoCapturerInterfaceImpl.cpp
platform/android/VideoCapturerInterfaceImpl.h
)
target_include_directories(lib_tgcalls
PUBLIC
${tgcalls_dir}

@ -1 +1 @@
Subproject commit 608b25bd32d01e233df0d78ccb5fd97028a82ae9
Subproject commit 3d5108a8787305ba7949659105b7f7490363488e