2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Revert "Add main window shadow for Linux"

This reverts commit d02092f09e.

Conflicts:
	Telegram/SourceFiles/mainwindow.cpp
	Telegram/SourceFiles/platform/linux/specific_linux.cpp
	Telegram/SourceFiles/window/main_window.cpp
This commit is contained in:
John Preston
2020-08-23 16:38:49 +04:00
parent 97076dbf83
commit b7f5cfe083
9 changed files with 54 additions and 361 deletions

View File

@@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "platform/platform_window_title.h"
#include "base/platform/base_platform_info.h"
#include "ui/platform/ui_platform_utility.h"
#include "history/history.h"
#include "window/themes/window_theme.h"
#include "window/window_session_controller.h"
@@ -34,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "facades.h"
#include "app.h"
#include "styles/style_window.h"
#include "styles/style_calls.h" // st::callShadow
#include <QtWidgets/QDesktopWidget>
#include <QtCore/QMimeData>
@@ -294,17 +292,6 @@ HitTestResult MainWindow::hitTest(const QPoint &p) const {
return Window::HitTestResult::None;
}
bool MainWindow::hasShadow() const {
const auto center = geometry().center();
return Platform::WindowsNeedShadow()
&& Ui::Platform::TranslucentWindowsSupported(center)
&& _title;
}
QRect MainWindow::inner() const {
return rect().marginsRemoved(_padding);
}
int MainWindow::computeMinWidth() const {
auto result = st::windowMinWidth;
if (const auto session = _controller->sessionController()) {
@@ -315,7 +302,7 @@ int MainWindow::computeMinWidth() const {
if (_rightColumn) {
result += _rightColumn->width();
}
return result + _padding.left() + _padding.right();
return result;
}
int MainWindow::computeMinHeight() const {
@@ -324,10 +311,10 @@ int MainWindow::computeMinHeight() const {
if (!_outdated) {
return 0;
}
_outdated->resizeToWidth(st::windowMinWidth - _padding.left() - _padding.right());
_outdated->resizeToWidth(st::windowMinWidth);
return _outdated->height();
}();
return title + outdated + st::windowMinHeight + _padding.top() + _padding.bottom();
return title + outdated + st::windowMinHeight;
}
void MainWindow::refreshTitleWidget() {
@@ -350,20 +337,7 @@ void MainWindow::updateMinimumSize() {
setMinimumHeight(computeMinHeight());
}
void MainWindow::updateShadowSize() {
_padding = hasShadow() && !isMaximized()
? st::callShadow.extend
: style::margins();
}
void MainWindow::recountGeometryConstraints() {
#ifdef Q_OS_LINUX
const auto hasShadow = this->hasShadow();
setWindowFlag(Qt::NoDropShadowWindowHint, hasShadow);
setAttribute(Qt::WA_OpaquePaintEvent, !hasShadow);
#endif // Q_OS_LINUX
updateShadowSize();
updateMinimumSize();
updateControlsGeometry();
fixOrder();
@@ -462,15 +436,7 @@ void MainWindow::attachToTrayIcon(not_null<QSystemTrayIcon*> icon) {
App::wnd()->updateTrayMenu();
}
void MainWindow::paintEvent(QPaintEvent *e) {
if (hasShadow() && !isMaximized()) {
QPainter p(this);
Ui::Shadow::paint(p, inner(), width(), st::callShadow);
}
}
void MainWindow::resizeEvent(QResizeEvent *e) {
updateShadowSize();
updateControlsGeometry();
}
@@ -483,28 +449,27 @@ void MainWindow::leaveEventHook(QEvent *e) {
}
void MainWindow::updateControlsGeometry() {
const auto inner = this->inner();
auto bodyLeft = inner.x();
auto bodyTop = inner.y();
auto bodyWidth = inner.width();
auto bodyLeft = 0;
auto bodyTop = 0;
auto bodyWidth = width();
if (_title && !_title->isHidden()) {
_title->setGeometry(inner.x(), bodyTop, inner.width(), _title->height());
_title->setGeometry(0, bodyTop, width(), _title->height());
bodyTop += _title->height();
}
if (_titleShadow) {
_titleShadow->setGeometry(inner.x(), bodyTop, inner.width(), st::lineWidth);
_titleShadow->setGeometry(0, bodyTop, width(), st::lineWidth);
}
if (_outdated) {
Ui::SendPendingMoveResizeEvents(_outdated.data());
_outdated->resizeToWidth(inner.width());
_outdated->moveToLeft(inner.x(), bodyTop);
_outdated->resizeToWidth(width());
_outdated->moveToLeft(0, bodyTop);
bodyTop += _outdated->height();
}
if (_rightColumn) {
bodyWidth -= _rightColumn->width();
_rightColumn->setGeometry(bodyWidth, bodyTop, inner.width() - bodyWidth, inner.height() - (bodyTop - inner.y()));
_rightColumn->setGeometry(bodyWidth, bodyTop, width() - bodyWidth, height() - bodyTop);
}
_body->setGeometry(bodyLeft, bodyTop, bodyWidth, inner.height() - (bodyTop - inner.y()));
_body->setGeometry(bodyLeft, bodyTop, bodyWidth, height() - bodyTop);
}
void MainWindow::updateUnreadCounter() {
@@ -634,12 +599,12 @@ void MainWindow::showRightColumn(object_ptr<TWidget> widget) {
int MainWindow::maximalExtendBy() const {
auto desktop = QDesktopWidget().availableGeometry(this);
return std::max(desktop.width() - inner().width(), 0);
return std::max(desktop.width() - geometry().width(), 0);
}
bool MainWindow::canExtendNoMove(int extendBy) const {
auto desktop = QDesktopWidget().availableGeometry(this);
auto inner = geometry().marginsRemoved(_padding);
auto inner = geometry();
auto innerRight = (inner.x() + inner.width() + extendBy);
auto desktopRight = (desktop.x() + desktop.width());
return innerRight <= desktopRight;