mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use new methods from lib_ui
This commit is contained in:
parent
f1ee5b5704
commit
15d18077b8
22 changed files with 31 additions and 670 deletions
|
@ -92,18 +92,6 @@ if (LINUX)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DESKTOP_APP_USE_PACKAGED
|
|
||||||
AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
|
|
||||||
AND Qt5WaylandClient_VERSION VERSION_LESS 5.13.0)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
|
|
||||||
|
|
||||||
target_include_directories(Telegram
|
|
||||||
PRIVATE
|
|
||||||
${WAYLAND_CLIENT_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION)
|
if (NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
|
@ -852,7 +840,6 @@ PRIVATE
|
||||||
platform/linux/notifications_manager_linux.h
|
platform/linux/notifications_manager_linux.h
|
||||||
platform/linux/specific_linux.cpp
|
platform/linux/specific_linux.cpp
|
||||||
platform/linux/specific_linux.h
|
platform/linux/specific_linux.h
|
||||||
platform/linux/window_title_linux.cpp
|
|
||||||
platform/linux/window_title_linux.h
|
platform/linux/window_title_linux.h
|
||||||
platform/mac/file_utilities_mac.mm
|
platform/mac/file_utilities_mac.mm
|
||||||
platform/mac/file_utilities_mac.h
|
platform/mac/file_utilities_mac.h
|
||||||
|
@ -1057,7 +1044,6 @@ PRIVATE
|
||||||
window/window_connecting_widget.h
|
window/window_connecting_widget.h
|
||||||
window/window_controller.cpp
|
window/window_controller.cpp
|
||||||
window/window_controller.h
|
window/window_controller.h
|
||||||
window/window_controls_layout.h
|
|
||||||
window/window_filters_menu.cpp
|
window/window_filters_menu.cpp
|
||||||
window/window_filters_menu.h
|
window/window_filters_menu.h
|
||||||
window/window_history_hider.cpp
|
window/window_history_hider.cpp
|
||||||
|
|
|
@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/local_url_handlers.h"
|
#include "core/local_url_handlers.h"
|
||||||
#include "core/launcher.h"
|
#include "core/launcher.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "core/core_settings.h"
|
|
||||||
#include "chat_helpers/emoji_keywords.h"
|
#include "chat_helpers/emoji_keywords.h"
|
||||||
#include "chat_helpers/stickers_emoji_image_loader.h"
|
#include "chat_helpers/stickers_emoji_image_loader.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
@ -212,8 +211,6 @@ void Application::run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::App().settings().setWindowControlsLayout(Platform::WindowControlsLayout());
|
|
||||||
|
|
||||||
_translator = std::make_unique<Lang::Translator>();
|
_translator = std::make_unique<Lang::Translator>();
|
||||||
QCoreApplication::instance()->installTranslator(_translator.get());
|
QCoreApplication::instance()->installTranslator(_translator.get());
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "window/themes/window_themes_embedded.h"
|
#include "window/themes/window_themes_embedded.h"
|
||||||
#include "window/window_controls_layout.h"
|
|
||||||
#include "ui/chat/attach/attach_send_files_way.h"
|
#include "ui/chat/attach/attach_send_files_way.h"
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
|
|
||||||
|
@ -503,18 +502,6 @@ public:
|
||||||
[[nodiscard]] rpl::producer<bool> systemDarkModeEnabledChanges() const {
|
[[nodiscard]] rpl::producer<bool> systemDarkModeEnabledChanges() const {
|
||||||
return _systemDarkModeEnabled.changes();
|
return _systemDarkModeEnabled.changes();
|
||||||
}
|
}
|
||||||
void setWindowControlsLayout(Window::ControlsLayout value) {
|
|
||||||
_windowControlsLayout = value;
|
|
||||||
}
|
|
||||||
[[nodiscard]] Window::ControlsLayout windowControlsLayout() const {
|
|
||||||
return _windowControlsLayout.current();
|
|
||||||
}
|
|
||||||
[[nodiscard]] rpl::producer<Window::ControlsLayout> windowControlsLayoutValue() const {
|
|
||||||
return _windowControlsLayout.value();
|
|
||||||
}
|
|
||||||
[[nodiscard]] rpl::producer<Window::ControlsLayout> windowControlsLayoutChanges() const {
|
|
||||||
return _windowControlsLayout.changes();
|
|
||||||
}
|
|
||||||
[[nodiscard]] const WindowPosition &windowPosition() const {
|
[[nodiscard]] const WindowPosition &windowPosition() const {
|
||||||
return _windowPosition;
|
return _windowPosition;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +589,6 @@ private:
|
||||||
rpl::variable<bool> _nativeWindowFrame = false;
|
rpl::variable<bool> _nativeWindowFrame = false;
|
||||||
rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
|
rpl::variable<std::optional<bool>> _systemDarkMode = std::nullopt;
|
||||||
rpl::variable<bool> _systemDarkModeEnabled = false;
|
rpl::variable<bool> _systemDarkModeEnabled = false;
|
||||||
rpl::variable<Window::ControlsLayout> _windowControlsLayout;
|
|
||||||
WindowPosition _windowPosition; // per-window
|
WindowPosition _windowPosition; // per-window
|
||||||
|
|
||||||
bool _tabbedReplacedWithInfo = false; // per-window
|
bool _tabbedReplacedWithInfo = false; // per-window
|
||||||
|
|
|
@ -38,9 +38,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "settings/settings_intro.h"
|
#include "settings/settings_intro.h"
|
||||||
#include "platform/platform_specific.h"
|
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
|
@ -111,7 +111,7 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
|
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
|
||||||
if (Platform::WindowsNeedShadow()) {
|
if (Ui::Platform::WindowExtentsSupported()) {
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
} else {
|
} else {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
|
@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "platform/platform_specific.h"
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -724,17 +723,9 @@ void PipPanel::startSystemDrag() {
|
||||||
|
|
||||||
const auto stateEdges = RectPartToQtEdges(*_dragState);
|
const auto stateEdges = RectPartToQtEdges(*_dragState);
|
||||||
if (stateEdges) {
|
if (stateEdges) {
|
||||||
if (!Platform::StartSystemResize(windowHandle(), stateEdges)) {
|
windowHandle()->startSystemResize(stateEdges);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
windowHandle()->startSystemResize(stateEdges);
|
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!Platform::StartSystemMove(windowHandle())) {
|
windowHandle()->startSystemMove();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
windowHandle()->startSystemMove();
|
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,13 +71,6 @@ void DarkModeChanged() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecorationLayoutChanged() {
|
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([] {
|
|
||||||
Core::App().settings().setWindowControlsLayout(
|
|
||||||
WindowControlsLayout());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
GtkIntegration::GtkIntegration() {
|
GtkIntegration::GtkIntegration() {
|
||||||
|
@ -182,10 +175,6 @@ void GtkIntegration::load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BaseGtkIntegration::Instance()->checkVersion(3, 12, 0)) {
|
if (BaseGtkIntegration::Instance()->checkVersion(3, 12, 0)) {
|
||||||
BaseGtkIntegration::Instance()->connectToSetting(
|
|
||||||
"gtk-decoration-layout",
|
|
||||||
DecorationLayoutChanged);
|
|
||||||
|
|
||||||
BaseGtkIntegration::Instance()->connectToSetting(
|
BaseGtkIntegration::Instance()->connectToSetting(
|
||||||
"gtk-decoration-layout",
|
"gtk-decoration-layout",
|
||||||
Ui::Platform::NotifyTitleControlsLayoutChanged);
|
Ui::Platform::NotifyTitleControlsLayoutChanged);
|
||||||
|
|
|
@ -9,52 +9,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
#include <QtGui/QWindow>
|
|
||||||
|
|
||||||
#include <private/qwaylanddisplay_p.h>
|
|
||||||
#include <private/qwaylandwindow_p.h>
|
|
||||||
#include <private/qwaylandshellsurface_p.h>
|
|
||||||
|
|
||||||
#include <connection_thread.h>
|
#include <connection_thread.h>
|
||||||
#include <registry.h>
|
#include <registry.h>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) && !defined DESKTOP_APP_QT_PATCHED
|
|
||||||
#include <wayland-client.h>
|
|
||||||
#endif // Qt < 5.13 && !DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
using QtWaylandClient::QWaylandWindow;
|
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) && !defined DESKTOP_APP_QT_PATCHED
|
|
||||||
enum wl_shell_surface_resize WlResizeFromEdges(Qt::Edges edges) {
|
|
||||||
if (edges == (Qt::TopEdge | Qt::LeftEdge))
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
|
|
||||||
if (edges == Qt::TopEdge)
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_TOP;
|
|
||||||
if (edges == (Qt::TopEdge | Qt::RightEdge))
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
|
|
||||||
if (edges == Qt::RightEdge)
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_RIGHT;
|
|
||||||
if (edges == (Qt::RightEdge | Qt::BottomEdge))
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
|
|
||||||
if (edges == Qt::BottomEdge)
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
|
||||||
if (edges == (Qt::BottomEdge | Qt::LeftEdge))
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
|
|
||||||
if (edges == Qt::LeftEdge)
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_LEFT;
|
|
||||||
|
|
||||||
return WL_SHELL_SURFACE_RESIZE_NONE;
|
|
||||||
}
|
|
||||||
#endif // Qt < 5.13 && !DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class WaylandIntegration::Private : public QObject {
|
class WaylandIntegration::Private : public QObject {
|
||||||
public:
|
public:
|
||||||
Private();
|
Private();
|
||||||
|
@ -95,7 +57,9 @@ WaylandIntegration::Private::Private() {
|
||||||
|
|
||||||
connect(&_registry, &Registry::interfacesAnnounced, [=] {
|
connect(&_registry, &Registry::interfacesAnnounced, [=] {
|
||||||
_interfacesAnnounced = true;
|
_interfacesAnnounced = true;
|
||||||
_interfacesLoop.quit();
|
if (_interfacesLoop.isRunning()) {
|
||||||
|
_interfacesLoop.quit();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_connection.initConnection();
|
_connection.initConnection();
|
||||||
|
@ -114,6 +78,7 @@ WaylandIntegration *WaylandIntegration::Instance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandIntegration::waitForInterfaceAnnounce() {
|
void WaylandIntegration::waitForInterfaceAnnounce() {
|
||||||
|
Expects(!_private->interfacesLoop().isRunning());
|
||||||
if (!_private->interfacesAnnounced()) {
|
if (!_private->interfacesAnnounced()) {
|
||||||
_private->interfacesLoop().exec();
|
_private->interfacesLoop().exec();
|
||||||
}
|
}
|
||||||
|
@ -124,58 +89,5 @@ bool WaylandIntegration::supportsXdgDecoration() {
|
||||||
Registry::Interface::XdgDecorationUnstableV1);
|
Registry::Interface::XdgDecorationUnstableV1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandIntegration::startMove(QWindow *window) {
|
|
||||||
// There are startSystemMove on Qt 5.15
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) && !defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (const auto waylandWindow = static_cast<QWaylandWindow*>(
|
|
||||||
window->handle())) {
|
|
||||||
if (const auto seat = waylandWindow->display()->lastInputDevice()) {
|
|
||||||
if (const auto shellSurface = waylandWindow->shellSurface()) {
|
|
||||||
return shellSurface->move(seat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::startResize(QWindow *window, Qt::Edges edges) {
|
|
||||||
// There are startSystemResize on Qt 5.15
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) && !defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (const auto waylandWindow = static_cast<QWaylandWindow*>(
|
|
||||||
window->handle())) {
|
|
||||||
if (const auto seat = waylandWindow->display()->lastInputDevice()) {
|
|
||||||
if (const auto shellSurface = waylandWindow->shellSurface()) {
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
|
||||||
shellSurface->resize(seat, edges);
|
|
||||||
return true;
|
|
||||||
#else // Qt >= 5.13
|
|
||||||
shellSurface->resize(seat, WlResizeFromEdges(edges));
|
|
||||||
return true;
|
|
||||||
#endif // Qt < 5.13
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // Qt < 5.15 && !DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::showWindowMenu(QWindow *window) {
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (const auto waylandWindow = static_cast<QWaylandWindow*>(
|
|
||||||
window->handle())) {
|
|
||||||
if (const auto seat = waylandWindow->display()->lastInputDevice()) {
|
|
||||||
if (const auto shellSurface = waylandWindow->shellSurface()) {
|
|
||||||
return shellSurface->showWindowMenu(seat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // Qt >= 5.13 || DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
@ -17,9 +17,6 @@ public:
|
||||||
static WaylandIntegration *Instance();
|
static WaylandIntegration *Instance();
|
||||||
void waitForInterfaceAnnounce();
|
void waitForInterfaceAnnounce();
|
||||||
bool supportsXdgDecoration();
|
bool supportsXdgDecoration();
|
||||||
bool startMove(QWindow *window);
|
|
||||||
bool startResize(QWindow *window, Qt::Edges edges);
|
|
||||||
bool showWindowMenu(QWindow *window);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WaylandIntegration();
|
WaylandIntegration();
|
||||||
|
|
|
@ -33,17 +33,5 @@ bool WaylandIntegration::supportsXdgDecoration() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandIntegration::startMove(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::startResize(QWindow *window, Qt::Edges edges) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaylandIntegration::showWindowMenu(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
@ -41,8 +41,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtDBus/QDBusError>
|
#include <QtDBus/QDBusError>
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -78,8 +76,6 @@ constexpr auto kXDGDesktopPortalService = "org.freedesktop.portal.Desktop"_cs;
|
||||||
constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs;
|
constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs;
|
||||||
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
||||||
|
|
||||||
constexpr auto kXCBFrameExtentsAtomName = "_GTK_FRAME_EXTENTS"_cs;
|
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
std::unique_ptr<internal::NotificationServiceWatcher> NSWInstance;
|
std::unique_ptr<internal::NotificationServiceWatcher> NSWInstance;
|
||||||
|
|
||||||
|
@ -351,187 +347,6 @@ bool GenerateDesktopFile(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint XCBMoveResizeFromEdges(Qt::Edges edges) {
|
|
||||||
if (edges == (Qt::TopEdge | Qt::LeftEdge))
|
|
||||||
return 0;
|
|
||||||
if (edges == Qt::TopEdge)
|
|
||||||
return 1;
|
|
||||||
if (edges == (Qt::TopEdge | Qt::RightEdge))
|
|
||||||
return 2;
|
|
||||||
if (edges == Qt::RightEdge)
|
|
||||||
return 3;
|
|
||||||
if (edges == (Qt::RightEdge | Qt::BottomEdge))
|
|
||||||
return 4;
|
|
||||||
if (edges == Qt::BottomEdge)
|
|
||||||
return 5;
|
|
||||||
if (edges == (Qt::BottomEdge | Qt::LeftEdge))
|
|
||||||
return 6;
|
|
||||||
if (edges == Qt::LeftEdge)
|
|
||||||
return 7;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartXCBMoveResize(QWindow *window, int edges) {
|
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
|
||||||
if (!connection) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto root = base::Platform::XCB::GetRootWindowFromQt();
|
|
||||||
if (!root.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto moveResizeAtom = base::Platform::XCB::GetAtom(
|
|
||||||
connection,
|
|
||||||
"_NET_WM_MOVERESIZE");
|
|
||||||
|
|
||||||
if (!moveResizeAtom.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto globalPos = QCursor::pos();
|
|
||||||
|
|
||||||
xcb_client_message_event_t xev;
|
|
||||||
xev.response_type = XCB_CLIENT_MESSAGE;
|
|
||||||
xev.type = *moveResizeAtom;
|
|
||||||
xev.sequence = 0;
|
|
||||||
xev.window = window->winId();
|
|
||||||
xev.format = 32;
|
|
||||||
xev.data.data32[0] = globalPos.x();
|
|
||||||
xev.data.data32[1] = globalPos.y();
|
|
||||||
xev.data.data32[2] = (edges == 16)
|
|
||||||
? 8 // move
|
|
||||||
: XCBMoveResizeFromEdges(Qt::Edges(edges));
|
|
||||||
xev.data.data32[3] = XCB_BUTTON_INDEX_1;
|
|
||||||
xev.data.data32[4] = 0;
|
|
||||||
|
|
||||||
xcb_ungrab_pointer(connection, XCB_CURRENT_TIME);
|
|
||||||
xcb_send_event(
|
|
||||||
connection,
|
|
||||||
false,
|
|
||||||
*root,
|
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
|
|
||||||
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
|
|
||||||
reinterpret_cast<const char*>(&xev));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShowXCBWindowMenu(QWindow *window) {
|
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
|
||||||
if (!connection) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto root = base::Platform::XCB::GetRootWindowFromQt();
|
|
||||||
if (!root.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto showWindowMenuAtom = base::Platform::XCB::GetAtom(
|
|
||||||
connection,
|
|
||||||
"_GTK_SHOW_WINDOW_MENU");
|
|
||||||
|
|
||||||
if (!showWindowMenuAtom.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto globalPos = QCursor::pos();
|
|
||||||
|
|
||||||
xcb_client_message_event_t xev;
|
|
||||||
xev.response_type = XCB_CLIENT_MESSAGE;
|
|
||||||
xev.type = *showWindowMenuAtom;
|
|
||||||
xev.sequence = 0;
|
|
||||||
xev.window = window->winId();
|
|
||||||
xev.format = 32;
|
|
||||||
xev.data.data32[0] = 0;
|
|
||||||
xev.data.data32[1] = globalPos.x();
|
|
||||||
xev.data.data32[2] = globalPos.y();
|
|
||||||
xev.data.data32[3] = 0;
|
|
||||||
xev.data.data32[4] = 0;
|
|
||||||
|
|
||||||
xcb_ungrab_pointer(connection, XCB_CURRENT_TIME);
|
|
||||||
xcb_send_event(
|
|
||||||
connection,
|
|
||||||
false,
|
|
||||||
*root,
|
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
|
|
||||||
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
|
|
||||||
reinterpret_cast<const char*>(&xev));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetXCBFrameExtents(QWindow *window, const QMargins &extents) {
|
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
|
||||||
if (!connection) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
|
||||||
connection,
|
|
||||||
kXCBFrameExtentsAtomName.utf16());
|
|
||||||
|
|
||||||
if (!frameExtentsAtom.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto extentsVector = std::vector<uint>{
|
|
||||||
uint(extents.left()),
|
|
||||||
uint(extents.right()),
|
|
||||||
uint(extents.top()),
|
|
||||||
uint(extents.bottom()),
|
|
||||||
};
|
|
||||||
|
|
||||||
xcb_change_property(
|
|
||||||
connection,
|
|
||||||
XCB_PROP_MODE_REPLACE,
|
|
||||||
window->winId(),
|
|
||||||
*frameExtentsAtom,
|
|
||||||
XCB_ATOM_CARDINAL,
|
|
||||||
32,
|
|
||||||
extentsVector.size(),
|
|
||||||
extentsVector.data());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UnsetXCBFrameExtents(QWindow *window) {
|
|
||||||
const auto connection = base::Platform::XCB::GetConnectionFromQt();
|
|
||||||
if (!connection) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto frameExtentsAtom = base::Platform::XCB::GetAtom(
|
|
||||||
connection,
|
|
||||||
kXCBFrameExtentsAtomName.utf16());
|
|
||||||
|
|
||||||
if (!frameExtentsAtom.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
xcb_delete_property(
|
|
||||||
connection,
|
|
||||||
window->winId(),
|
|
||||||
*frameExtentsAtom);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window::Control GtkKeywordToWindowControl(const QString &keyword) {
|
|
||||||
if (keyword == qstr("minimize")) {
|
|
||||||
return Window::Control::Minimize;
|
|
||||||
} else if (keyword == qstr("maximize")) {
|
|
||||||
return Window::Control::Maximize;
|
|
||||||
} else if (keyword == qstr("close")) {
|
|
||||||
return Window::Control::Close;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Window::Control::Unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void SetWatchingMediaKeys(bool watching) {
|
void SetWatchingMediaKeys(bool watching) {
|
||||||
|
@ -741,129 +556,6 @@ bool SkipTaskbarSupported() {
|
||||||
&& base::Platform::XCB::IsSupportedByWM("_NET_WM_STATE_SKIP_TASKBAR");
|
&& base::Platform::XCB::IsSupportedByWM("_NET_WM_STATE_SKIP_TASKBAR");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartSystemMove(QWindow *window) {
|
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
|
||||||
return integration->startMove(window);
|
|
||||||
} else {
|
|
||||||
return StartXCBMoveResize(window, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StartSystemResize(QWindow *window, Qt::Edges edges) {
|
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
|
||||||
return integration->startResize(window, edges);
|
|
||||||
} else {
|
|
||||||
return StartXCBMoveResize(window, edges);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShowWindowMenu(QWindow *window) {
|
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
|
||||||
return integration->showWindowMenu(window);
|
|
||||||
} else {
|
|
||||||
return ShowXCBWindowMenu(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
|
||||||
if (IsWayland()) {
|
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
|
||||||
window->setProperty("WaylandCustomMargins", QVariant::fromValue<QMargins>(extents));
|
|
||||||
return true;
|
|
||||||
#else // DESKTOP_APP_QT_PATCHED
|
|
||||||
return false;
|
|
||||||
#endif // !DESKTOP_APP_QT_PATCHED
|
|
||||||
} else {
|
|
||||||
return SetXCBFrameExtents(window, extents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UnsetWindowExtents(QWindow *window) {
|
|
||||||
if (IsWayland()) {
|
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
|
||||||
window->setProperty("WaylandCustomMargins", QVariant());
|
|
||||||
return true;
|
|
||||||
#else // DESKTOP_APP_QT_PATCHED
|
|
||||||
return false;
|
|
||||||
#endif // !DESKTOP_APP_QT_PATCHED
|
|
||||||
} else {
|
|
||||||
return UnsetXCBFrameExtents(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowsNeedShadow() {
|
|
||||||
#ifdef DESKTOP_APP_QT_PATCHED
|
|
||||||
if (IsWayland()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif // DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
namespace XCB = base::Platform::XCB;
|
|
||||||
if (!IsWayland()
|
|
||||||
&& XCB::IsSupportedByWM(kXCBFrameExtentsAtomName.utf16())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window::ControlsLayout WindowControlsLayout() {
|
|
||||||
const auto gtkResult = []() -> std::optional<Window::ControlsLayout> {
|
|
||||||
const auto integration = BaseGtkIntegration::Instance();
|
|
||||||
if (!integration || !integration->checkVersion(3, 12, 0)) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto decorationLayoutSetting = integration->getStringSetting(
|
|
||||||
qsl("gtk-decoration-layout"));
|
|
||||||
|
|
||||||
if (!decorationLayoutSetting.has_value()) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto decorationLayout = decorationLayoutSetting->split(':');
|
|
||||||
|
|
||||||
std::vector<Window::Control> controlsLeft;
|
|
||||||
ranges::transform(
|
|
||||||
decorationLayout[0].split(','),
|
|
||||||
ranges::back_inserter(controlsLeft),
|
|
||||||
GtkKeywordToWindowControl);
|
|
||||||
|
|
||||||
std::vector<Window::Control> controlsRight;
|
|
||||||
if (decorationLayout.size() > 1) {
|
|
||||||
ranges::transform(
|
|
||||||
decorationLayout[1].split(','),
|
|
||||||
ranges::back_inserter(controlsRight),
|
|
||||||
GtkKeywordToWindowControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Window::ControlsLayout{
|
|
||||||
.left = controlsLeft,
|
|
||||||
.right = controlsRight
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (gtkResult.has_value()) {
|
|
||||||
return *gtkResult;
|
|
||||||
} else if (DesktopEnvironment::IsUnity()) {
|
|
||||||
return Window::ControlsLayout{
|
|
||||||
.left = {
|
|
||||||
Window::Control::Close,
|
|
||||||
Window::Control::Minimize,
|
|
||||||
Window::Control::Maximize,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return Window::ControlsLayout{
|
|
||||||
.right = {
|
|
||||||
Window::Control::Minimize,
|
|
||||||
Window::Control::Maximize,
|
|
||||||
Window::Control::Close,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
QRect psDesktopRect() {
|
QRect psDesktopRect() {
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop application for the Telegram messaging service.
|
|
||||||
|
|
||||||
For license and copyright information please follow this link:
|
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
||||||
*/
|
|
||||||
#include "platform/linux/window_title_linux.h"
|
|
||||||
|
|
||||||
#include "platform/linux/linux_wayland_integration.h"
|
|
||||||
#include "base/platform/base_platform_info.h"
|
|
||||||
|
|
||||||
namespace Platform {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
bool SystemMoveResizeSupported() {
|
|
||||||
#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
return true;
|
|
||||||
#else // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
return !IsWayland();
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION || Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool AllowNativeWindowFrameToggle() {
|
|
||||||
const auto waylandIntegration = internal::WaylandIntegration::Instance();
|
|
||||||
return SystemMoveResizeSupported()
|
|
||||||
&& (!waylandIntegration
|
|
||||||
|| waylandIntegration->supportsXdgDecoration());
|
|
||||||
}
|
|
||||||
|
|
||||||
object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
|
||||||
return SystemMoveResizeSupported()
|
|
||||||
? object_ptr<Window::TitleWidgetQt>(parent)
|
|
||||||
: object_ptr<Window::TitleWidgetQt>{ nullptr };
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "platform/platform_window_title.h"
|
#include "platform/platform_window_title.h"
|
||||||
|
#include "platform/linux/linux_wayland_integration.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -21,8 +22,15 @@ void DefaultPreviewWindowFramePaint(QImage &preview, const style::palette &palet
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
bool AllowNativeWindowFrameToggle();
|
inline bool AllowNativeWindowFrameToggle() {
|
||||||
object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent);
|
const auto waylandIntegration = internal::WaylandIntegration::Instance();
|
||||||
|
return !waylandIntegration
|
||||||
|
|| waylandIntegration->supportsXdgDecoration();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
||||||
|
return object_ptr<Window::TitleWidgetQt>(parent);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool NativeTitleRequiresShadow() {
|
inline bool NativeTitleRequiresShadow() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,18 +22,6 @@ inline QImage GetImageFromClipboard() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool StartSystemMove(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool StartSystemResize(QWindow *window, Qt::Edges edges) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ShowWindowMenu(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool AutostartSupported() {
|
inline bool AutostartSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -46,18 +34,6 @@ inline bool SkipTaskbarSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool UnsetWindowExtents(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool WindowsNeedShadow() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
|
||||||
inline void start() {
|
inline void start() {
|
||||||
|
|
|
@ -203,16 +203,6 @@ void IgnoreApplicationActivationRightNow() {
|
||||||
objc_ignoreApplicationActivationRightNow();
|
objc_ignoreApplicationActivationRightNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::ControlsLayout WindowControlsLayout() {
|
|
||||||
return Window::ControlsLayout{
|
|
||||||
.left = {
|
|
||||||
Window::Control::Close,
|
|
||||||
Window::Control::Minimize,
|
|
||||||
Window::Control::Maximize,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
void psNewVersion() {
|
void psNewVersion() {
|
||||||
|
|
|
@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "window/window_controls_layout.h"
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
@ -42,13 +40,6 @@ bool AutostartSupported();
|
||||||
bool TrayIconSupported();
|
bool TrayIconSupported();
|
||||||
bool SkipTaskbarSupported();
|
bool SkipTaskbarSupported();
|
||||||
QImage GetImageFromClipboard();
|
QImage GetImageFromClipboard();
|
||||||
bool StartSystemMove(QWindow *window);
|
|
||||||
bool StartSystemResize(QWindow *window, Qt::Edges edges);
|
|
||||||
bool ShowWindowMenu(QWindow *window);
|
|
||||||
bool WindowsNeedShadow();
|
|
||||||
bool SetWindowExtents(QWindow *window, const QMargins &extents);
|
|
||||||
bool UnsetWindowExtents(QWindow *window);
|
|
||||||
Window::ControlsLayout WindowControlsLayout();
|
|
||||||
|
|
||||||
[[nodiscard]] std::optional<bool> IsDarkMode();
|
[[nodiscard]] std::optional<bool> IsDarkMode();
|
||||||
[[nodiscard]] inline bool IsDarkModeSupported() {
|
[[nodiscard]] inline bool IsDarkModeSupported() {
|
||||||
|
|
|
@ -312,28 +312,6 @@ bool AutostartSupported() {
|
||||||
return !IsWindowsStoreBuild();
|
return !IsWindowsStoreBuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShowWindowMenu(QWindow *window) {
|
|
||||||
const auto pos = QCursor::pos();
|
|
||||||
|
|
||||||
SendMessage(
|
|
||||||
HWND(window->winId()),
|
|
||||||
WM_SYSCOMMAND,
|
|
||||||
SC_MOUSEMENU,
|
|
||||||
MAKELPARAM(pos.x(), pos.y()));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Window::ControlsLayout WindowControlsLayout() {
|
|
||||||
return Window::ControlsLayout{
|
|
||||||
.right = {
|
|
||||||
Window::Control::Minimize,
|
|
||||||
Window::Control::Maximize,
|
|
||||||
Window::Control::Close,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -26,14 +26,6 @@ inline QImage GetImageFromClipboard() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool StartSystemMove(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool StartSystemResize(QWindow *window, Qt::Edges edges) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool TrayIconSupported() {
|
inline bool TrayIconSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,18 +34,6 @@ inline bool SkipTaskbarSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetWindowExtents(QWindow *window, const QMargins &extents) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool UnsetWindowExtents(QWindow *window) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool WindowsNeedShadow() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ThirdParty {
|
namespace ThirdParty {
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/separate_panel.h"
|
#include "ui/widgets/separate_panel.h"
|
||||||
|
|
||||||
#include "window/main_window.h"
|
#include "window/main_window.h"
|
||||||
#include "platform/platform_specific.h"
|
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -554,14 +553,9 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
if (dragArea.contains(e->pos())) {
|
if (dragArea.contains(e->pos())) {
|
||||||
const auto dragViaSystem = [&] {
|
const auto dragViaSystem = [&] {
|
||||||
if (::Platform::StartSystemMove(windowHandle())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (windowHandle()->startSystemMove()) {
|
if (windowHandle()->startSystemMove()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
return false;
|
return false;
|
||||||
}();
|
}();
|
||||||
if (!dragViaSystem) {
|
if (!dragViaSystem) {
|
||||||
|
|
|
@ -346,7 +346,7 @@ HitTestResult MainWindow::hitTest(const QPoint &p) const {
|
||||||
|
|
||||||
bool MainWindow::hasShadow() const {
|
bool MainWindow::hasShadow() const {
|
||||||
const auto center = geometry().center();
|
const auto center = geometry().center();
|
||||||
return Platform::WindowsNeedShadow()
|
return Ui::Platform::WindowExtentsSupported()
|
||||||
&& Ui::Platform::TranslucentWindowsSupported(center)
|
&& Ui::Platform::TranslucentWindowsSupported(center)
|
||||||
&& _title;
|
&& _title;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop application for the Telegram messaging service.
|
|
||||||
|
|
||||||
For license and copyright information please follow this link:
|
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace Window {
|
|
||||||
|
|
||||||
enum class Control {
|
|
||||||
Unknown,
|
|
||||||
Minimize,
|
|
||||||
Maximize,
|
|
||||||
Close,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ControlsLayout {
|
|
||||||
std::vector<Control> left;
|
|
||||||
std::vector<Control> right;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Window
|
|
|
@ -7,12 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/window_title_qt.h"
|
#include "window/window_title_qt.h"
|
||||||
|
|
||||||
#include "platform/platform_specific.h"
|
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "core/core_settings.h"
|
|
||||||
#include "core/application.h"
|
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
|
@ -66,7 +63,7 @@ TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
||||||
});
|
});
|
||||||
_close->setPointerCursor(false);
|
_close->setPointerCursor(false);
|
||||||
|
|
||||||
Core::App().settings().windowControlsLayoutChanges(
|
Ui::Platform::TitleControlsLayoutChanged(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateControlsPosition();
|
updateControlsPosition();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -94,7 +91,7 @@ TitleWidgetQt::~TitleWidgetQt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_extentsSet) {
|
if (_extentsSet) {
|
||||||
Platform::UnsetWindowExtents(window()->windowHandle());
|
Ui::Platform::UnsetWindowExtents(window()->windowHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +113,7 @@ void TitleWidgetQt::init() {
|
||||||
|
|
||||||
bool TitleWidgetQt::hasShadow() const {
|
bool TitleWidgetQt::hasShadow() const {
|
||||||
const auto center = window()->geometry().center();
|
const auto center = window()->geometry().center();
|
||||||
return Platform::WindowsNeedShadow()
|
return Ui::Platform::WindowExtentsSupported()
|
||||||
&& Ui::Platform::TranslucentWindowsSupported(center);
|
&& Ui::Platform::TranslucentWindowsSupported(center);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,19 +142,19 @@ void TitleWidgetQt::toggleFramelessWindow(bool enabled) {
|
||||||
|
|
||||||
void TitleWidgetQt::updateWindowExtents() {
|
void TitleWidgetQt::updateWindowExtents() {
|
||||||
if (hasShadow()) {
|
if (hasShadow()) {
|
||||||
Platform::SetWindowExtents(
|
Ui::Platform::SetWindowExtents(
|
||||||
window()->windowHandle(),
|
window()->windowHandle(),
|
||||||
resizeArea() * cIntRetinaFactor());
|
resizeArea() * cIntRetinaFactor());
|
||||||
|
|
||||||
_extentsSet = true;
|
_extentsSet = true;
|
||||||
} else if (_extentsSet) {
|
} else if (_extentsSet) {
|
||||||
Platform::UnsetWindowExtents(window()->windowHandle());
|
Ui::Platform::UnsetWindowExtents(window()->windowHandle());
|
||||||
_extentsSet = false;
|
_extentsSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::updateControlsPosition() {
|
void TitleWidgetQt::updateControlsPosition() {
|
||||||
const auto controlsLayout = Core::App().settings().windowControlsLayout();
|
const auto controlsLayout = Ui::Platform::TitleControlsLayout();
|
||||||
const auto controlsLeft = controlsLayout.left;
|
const auto controlsLeft = controlsLayout.left;
|
||||||
const auto controlsRight = controlsLayout.right;
|
const auto controlsRight = controlsLayout.right;
|
||||||
|
|
||||||
|
@ -223,7 +220,7 @@ void TitleWidgetQt::mousePressEvent(QMouseEvent *e) {
|
||||||
if (e->button() == Qt::LeftButton) {
|
if (e->button() == Qt::LeftButton) {
|
||||||
_mousePressed = true;
|
_mousePressed = true;
|
||||||
} else if (e->button() == Qt::RightButton) {
|
} else if (e->button() == Qt::RightButton) {
|
||||||
Platform::ShowWindowMenu(window()->windowHandle());
|
Ui::Platform::ShowWindowMenu(window()->windowHandle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +232,7 @@ void TitleWidgetQt::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
void TitleWidgetQt::mouseMoveEvent(QMouseEvent *e) {
|
void TitleWidgetQt::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if (_mousePressed) {
|
if (_mousePressed) {
|
||||||
startMove();
|
window()->windowHandle()->startSystemMove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +261,7 @@ bool TitleWidgetQt::eventFilter(QObject *obj, QEvent *e) {
|
||||||
if (e->type() == QEvent::MouseButtonPress
|
if (e->type() == QEvent::MouseButtonPress
|
||||||
&& mouseEvent->button() == Qt::LeftButton
|
&& mouseEvent->button() == Qt::LeftButton
|
||||||
&& edges) {
|
&& edges) {
|
||||||
return startResize(edges);
|
return window()->windowHandle()->startSystemResize(edges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e->type() == QEvent::Leave) {
|
} else if (e->type() == QEvent::Leave) {
|
||||||
|
@ -413,32 +410,4 @@ void TitleWidgetQt::restoreCursor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TitleWidgetQt::startMove() {
|
|
||||||
if (Platform::StartSystemMove(window()->windowHandle())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (window()->windowHandle()->startSystemMove()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TitleWidgetQt::startResize(Qt::Edges edges) {
|
|
||||||
if (Platform::StartSystemResize(window()->windowHandle(), edges)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
|
|
||||||
if (window()->windowHandle()->startSystemResize(edges)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
|
@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "window/window_title.h"
|
#include "window/window_title.h"
|
||||||
#include "window/window_controls_layout.h"
|
#include "ui/platform/ui_platform_window_title.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
|
@ -24,6 +24,8 @@ namespace Window {
|
||||||
|
|
||||||
class TitleWidgetQt : public TitleWidget {
|
class TitleWidgetQt : public TitleWidget {
|
||||||
public:
|
public:
|
||||||
|
using Control = Ui::Platform::TitleControls::Control;
|
||||||
|
|
||||||
TitleWidgetQt(QWidget *parent);
|
TitleWidgetQt(QWidget *parent);
|
||||||
~TitleWidgetQt();
|
~TitleWidgetQt();
|
||||||
|
|
||||||
|
@ -56,8 +58,6 @@ private:
|
||||||
Qt::Edges edgesFromPos(const QPoint &pos) const;
|
Qt::Edges edgesFromPos(const QPoint &pos) const;
|
||||||
void updateCursor(Qt::Edges edges);
|
void updateCursor(Qt::Edges edges);
|
||||||
void restoreCursor();
|
void restoreCursor();
|
||||||
bool startMove();
|
|
||||||
bool startResize(Qt::Edges edges);
|
|
||||||
|
|
||||||
const style::WindowTitle &_st;
|
const style::WindowTitle &_st;
|
||||||
object_ptr<Ui::IconButton> _minimize;
|
object_ptr<Ui::IconButton> _minimize;
|
||||||
|
|
Loading…
Add table
Reference in a new issue