mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved Windows SMTC as part of cross-platform media controls solution.
This commit is contained in:
parent
f90f1c02c3
commit
1cfbf24635
9 changed files with 42 additions and 31 deletions
|
@ -943,8 +943,6 @@ PRIVATE
|
||||||
platform/win/windows_dlls.h
|
platform/win/windows_dlls.h
|
||||||
platform/win/windows_event_filter.cpp
|
platform/win/windows_event_filter.cpp
|
||||||
platform/win/windows_event_filter.h
|
platform/win/windows_event_filter.h
|
||||||
platform/win/windows_system_media_controls_manager.cpp
|
|
||||||
platform/win/windows_system_media_controls_manager.h
|
|
||||||
platform/platform_audio.h
|
platform/platform_audio.h
|
||||||
platform/platform_file_utilities.h
|
platform/platform_file_utilities.h
|
||||||
platform/platform_launcher.h
|
platform/platform_launcher.h
|
||||||
|
@ -1088,6 +1086,8 @@ PRIVATE
|
||||||
window/section_memento.h
|
window/section_memento.h
|
||||||
window/section_widget.cpp
|
window/section_widget.cpp
|
||||||
window/section_widget.h
|
window/section_widget.h
|
||||||
|
window/system_media_controls_manager.cpp
|
||||||
|
window/system_media_controls_manager.h
|
||||||
window/window_connecting_widget.cpp
|
window/window_connecting_widget.cpp
|
||||||
window/window_connecting_widget.h
|
window/window_connecting_widget.h
|
||||||
window/window_controller.cpp
|
window/window_controller.cpp
|
||||||
|
|
|
@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "window/themes/window_theme_warning.h"
|
#include "window/themes/window_theme_warning.h"
|
||||||
|
#include "window/system_media_controls_manager.h"
|
||||||
#include "window/window_lock_widgets.h"
|
#include "window/window_lock_widgets.h"
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
#include "window/window_controller.h" // App::wnd.
|
#include "window/window_controller.h" // App::wnd.
|
||||||
|
@ -81,7 +82,11 @@ void FeedLangTestingKey(int key) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
: Platform::MainWindow(controller) {
|
: Platform::MainWindow(controller)
|
||||||
|
, _mediaControlsManager(Window::SystemMediaControlsManager::Supported()
|
||||||
|
? std::make_unique<Window::SystemMediaControlsManager>(this)
|
||||||
|
: nullptr) {
|
||||||
|
|
||||||
auto logo = Core::App().logo();
|
auto logo = Core::App().logo();
|
||||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||||
|
|
|
@ -24,6 +24,7 @@ class MediaPreviewWidget;
|
||||||
class SectionMemento;
|
class SectionMemento;
|
||||||
struct SectionShow;
|
struct SectionShow;
|
||||||
class PasscodeLockWidget;
|
class PasscodeLockWidget;
|
||||||
|
class SystemMediaControlsManager;
|
||||||
namespace Theme {
|
namespace Theme {
|
||||||
struct BackgroundUpdate;
|
struct BackgroundUpdate;
|
||||||
class WarningWidget;
|
class WarningWidget;
|
||||||
|
@ -130,6 +131,9 @@ private:
|
||||||
|
|
||||||
QPixmap grabInner();
|
QPixmap grabInner();
|
||||||
|
|
||||||
|
using MediaControlsManager = Window::SystemMediaControlsManager;
|
||||||
|
const std::unique_ptr<MediaControlsManager> _mediaControlsManager;
|
||||||
|
|
||||||
QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64;
|
QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64;
|
||||||
|
|
||||||
crl::time _lastTrayClickTime = 0;
|
crl::time _lastTrayClickTime = 0;
|
||||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "platform/win/windows_dlls.h"
|
#include "platform/win/windows_dlls.h"
|
||||||
#include "platform/win/windows_event_filter.h"
|
#include "platform/win/windows_event_filter.h"
|
||||||
#include "platform/win/windows_system_media_controls_manager.h"
|
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "base/crc32hash.h"
|
#include "base/crc32hash.h"
|
||||||
|
@ -431,10 +430,6 @@ void MainWindow::initHook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
psInitSysMenu();
|
psInitSysMenu();
|
||||||
|
|
||||||
if (IsWindows10OrGreater()) {
|
|
||||||
_smtcManager = std::make_unique<SystemMediaControlsManager>(psHwnd());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initShadows() {
|
void MainWindow::initShadows() {
|
||||||
|
|
|
@ -20,8 +20,6 @@ class PopupMenu;
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
class SystemMediaControlsManager;
|
|
||||||
|
|
||||||
class MainWindow : public Window::MainWindow {
|
class MainWindow : public Window::MainWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
@ -125,8 +123,6 @@ private:
|
||||||
HICON ps_iconSmall = nullptr;
|
HICON ps_iconSmall = nullptr;
|
||||||
HICON ps_iconOverlay = nullptr;
|
HICON ps_iconOverlay = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<Platform::SystemMediaControlsManager> _smtcManager;
|
|
||||||
|
|
||||||
int _deltaLeft = 0;
|
int _deltaLeft = 0;
|
||||||
int _deltaTop = 0;
|
int _deltaTop = 0;
|
||||||
int _deltaRight = 0;
|
int _deltaRight = 0;
|
||||||
|
|
|
@ -5,10 +5,10 @@ the official desktop application for the Telegram messaging service.
|
||||||
For license and copyright information please follow this link:
|
For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "platform/win/windows_system_media_controls_manager.h"
|
#include "window/system_media_controls_manager.h"
|
||||||
|
|
||||||
#include "base/observer.h"
|
#include "base/observer.h"
|
||||||
#include "base/platform/win/base_windows_system_media_controls.h"
|
#include "base/platform/base_platform_system_media_controls.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
|
@ -18,16 +18,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "ui/text/format_song_document_name.h"
|
#include "ui/text/format_song_document_name.h"
|
||||||
|
|
||||||
namespace Platform {
|
namespace Window {
|
||||||
|
|
||||||
SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
bool SystemMediaControlsManager::Supported() {
|
||||||
: _controls(std::make_unique<base::Platform::SystemMediaControlsWin>()) {
|
return base::Platform::SystemMediaControls::Supported();
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemMediaControlsManager::SystemMediaControlsManager(
|
||||||
|
not_null<QWidget*> parent)
|
||||||
|
: _controls(std::make_unique<base::Platform::SystemMediaControls>()) {
|
||||||
|
|
||||||
using PlaybackStatus =
|
using PlaybackStatus =
|
||||||
base::Platform::SystemMediaControlsWin::PlaybackStatus;
|
base::Platform::SystemMediaControls::PlaybackStatus;
|
||||||
using Command = base::Platform::SystemMediaControlsWin::Command;
|
using Command = base::Platform::SystemMediaControls::Command;
|
||||||
|
|
||||||
_controls->init(hwnd);
|
const auto inited = _controls->init(parent.get());
|
||||||
|
if (!inited) {
|
||||||
|
LOG(("SystemMediaControlsManager failed to init."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto type = AudioMsgId::Type::Song;
|
const auto type = AudioMsgId::Type::Song;
|
||||||
|
|
||||||
const auto mediaPlayer = Media::Player::instance();
|
const auto mediaPlayer = Media::Player::instance();
|
||||||
|
@ -52,8 +61,8 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||||
mediaPlayer->stops(type) | rpl::map_to(false),
|
mediaPlayer->stops(type) | rpl::map_to(false),
|
||||||
mediaPlayer->startsPlay(type) | rpl::map_to(true)
|
mediaPlayer->startsPlay(type) | rpl::map_to(true)
|
||||||
) | rpl::start_with_next([=](bool audio) {
|
) | rpl::start_with_next([=](bool audio) {
|
||||||
|
_controls->setEnabled(audio);
|
||||||
if (audio) {
|
if (audio) {
|
||||||
_controls->setEnabled(audio);
|
|
||||||
_controls->setIsNextEnabled(mediaPlayer->nextAvailable(type));
|
_controls->setIsNextEnabled(mediaPlayer->nextAvailable(type));
|
||||||
_controls->setIsPreviousEnabled(
|
_controls->setIsPreviousEnabled(
|
||||||
mediaPlayer->previousAvailable(type));
|
mediaPlayer->previousAvailable(type));
|
||||||
|
@ -75,8 +84,8 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||||
});
|
});
|
||||||
|
|
||||||
auto unlocked = Core::App().passcodeLockChanges(
|
auto unlocked = Core::App().passcodeLockChanges(
|
||||||
) | rpl::filter([](bool locked) {
|
) | rpl::filter([=](bool locked) {
|
||||||
return !locked;
|
return !locked && (mediaPlayer->current(type));
|
||||||
}) | rpl::map([=] {
|
}) | rpl::map([=] {
|
||||||
return type;
|
return type;
|
||||||
}) | rpl::before_next([=] {
|
}) | rpl::before_next([=] {
|
||||||
|
@ -145,4 +154,4 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||||
|
|
||||||
SystemMediaControlsManager::~SystemMediaControlsManager() = default;
|
SystemMediaControlsManager::~SystemMediaControlsManager() = default;
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Window
|
|
@ -8,22 +8,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace base::Platform {
|
namespace base::Platform {
|
||||||
class SystemMediaControlsWin;
|
class SystemMediaControls;
|
||||||
} // namespace base::Platform
|
} // namespace base::Platform
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class DocumentMedia;
|
class DocumentMedia;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Platform {
|
namespace Window {
|
||||||
|
|
||||||
class SystemMediaControlsManager {
|
class SystemMediaControlsManager {
|
||||||
public:
|
public:
|
||||||
SystemMediaControlsManager(HWND hwnd);
|
SystemMediaControlsManager(not_null<QWidget*> parent);
|
||||||
~SystemMediaControlsManager();
|
~SystemMediaControlsManager();
|
||||||
|
|
||||||
|
static bool Supported();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<base::Platform::SystemMediaControlsWin> _controls;
|
const std::unique_ptr<base::Platform::SystemMediaControls> _controls;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Data::DocumentMedia>> _cachedMediaView;
|
std::vector<std::shared_ptr<Data::DocumentMedia>> _cachedMediaView;
|
||||||
|
|
||||||
|
@ -31,4 +33,4 @@ private:
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Window
|
|
@ -1 +1 @@
|
||||||
Subproject commit 846282f36fc4270a1d6b926163d104b40800e781
|
Subproject commit 3f791f9794b102c5c14485e0f25df2e18b49f129
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
||||||
Subproject commit 4caa8674681fb50a2244b58eb701508017c360d6
|
Subproject commit 03efe01ff978b84745414e046e4766225ffffb7f
|
Loading…
Add table
Reference in a new issue