mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-24 01:06:59 +00:00
Moved Windows SMTC as part of cross-platform media controls solution.
This commit is contained in:
parent
f90f1c02c3
commit
1cfbf24635
@ -943,8 +943,6 @@ PRIVATE
|
||||
platform/win/windows_dlls.h
|
||||
platform/win/windows_event_filter.cpp
|
||||
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_file_utilities.h
|
||||
platform/platform_launcher.h
|
||||
@ -1088,6 +1086,8 @@ PRIVATE
|
||||
window/section_memento.h
|
||||
window/section_widget.cpp
|
||||
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.h
|
||||
window/window_controller.cpp
|
||||
|
@ -45,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "window/notifications_manager.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/themes/window_theme_warning.h"
|
||||
#include "window/system_media_controls_manager.h"
|
||||
#include "window/window_lock_widgets.h"
|
||||
#include "window/window_main_menu.h"
|
||||
#include "window/window_controller.h" // App::wnd.
|
||||
@ -81,7 +82,11 @@ void FeedLangTestingKey(int key) {
|
||||
} // namespace
|
||||
|
||||
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();
|
||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
|
@ -24,6 +24,7 @@ class MediaPreviewWidget;
|
||||
class SectionMemento;
|
||||
struct SectionShow;
|
||||
class PasscodeLockWidget;
|
||||
class SystemMediaControlsManager;
|
||||
namespace Theme {
|
||||
struct BackgroundUpdate;
|
||||
class WarningWidget;
|
||||
@ -130,6 +131,9 @@ private:
|
||||
|
||||
QPixmap grabInner();
|
||||
|
||||
using MediaControlsManager = Window::SystemMediaControlsManager;
|
||||
const std::unique_ptr<MediaControlsManager> _mediaControlsManager;
|
||||
|
||||
QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64;
|
||||
|
||||
crl::time _lastTrayClickTime = 0;
|
||||
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "platform/win/windows_dlls.h"
|
||||
#include "platform/win/windows_event_filter.h"
|
||||
#include "platform/win/windows_system_media_controls_manager.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "mainwindow.h"
|
||||
#include "base/crc32hash.h"
|
||||
@ -431,10 +430,6 @@ void MainWindow::initHook() {
|
||||
}
|
||||
|
||||
psInitSysMenu();
|
||||
|
||||
if (IsWindows10OrGreater()) {
|
||||
_smtcManager = std::make_unique<SystemMediaControlsManager>(psHwnd());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::initShadows() {
|
||||
|
@ -20,8 +20,6 @@ class PopupMenu;
|
||||
|
||||
namespace Platform {
|
||||
|
||||
class SystemMediaControlsManager;
|
||||
|
||||
class MainWindow : public Window::MainWindow {
|
||||
public:
|
||||
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||
@ -125,8 +123,6 @@ private:
|
||||
HICON ps_iconSmall = nullptr;
|
||||
HICON ps_iconOverlay = nullptr;
|
||||
|
||||
std::unique_ptr<Platform::SystemMediaControlsManager> _smtcManager;
|
||||
|
||||
int _deltaLeft = 0;
|
||||
int _deltaTop = 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:
|
||||
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/platform/win/base_windows_system_media_controls.h"
|
||||
#include "base/platform/base_platform_system_media_controls.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_document.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 "ui/text/format_song_document_name.h"
|
||||
|
||||
namespace Platform {
|
||||
namespace Window {
|
||||
|
||||
SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||
: _controls(std::make_unique<base::Platform::SystemMediaControlsWin>()) {
|
||||
bool SystemMediaControlsManager::Supported() {
|
||||
return base::Platform::SystemMediaControls::Supported();
|
||||
}
|
||||
|
||||
SystemMediaControlsManager::SystemMediaControlsManager(
|
||||
not_null<QWidget*> parent)
|
||||
: _controls(std::make_unique<base::Platform::SystemMediaControls>()) {
|
||||
|
||||
using PlaybackStatus =
|
||||
base::Platform::SystemMediaControlsWin::PlaybackStatus;
|
||||
using Command = base::Platform::SystemMediaControlsWin::Command;
|
||||
base::Platform::SystemMediaControls::PlaybackStatus;
|
||||
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 mediaPlayer = Media::Player::instance();
|
||||
@ -52,8 +61,8 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||
mediaPlayer->stops(type) | rpl::map_to(false),
|
||||
mediaPlayer->startsPlay(type) | rpl::map_to(true)
|
||||
) | rpl::start_with_next([=](bool audio) {
|
||||
_controls->setEnabled(audio);
|
||||
if (audio) {
|
||||
_controls->setEnabled(audio);
|
||||
_controls->setIsNextEnabled(mediaPlayer->nextAvailable(type));
|
||||
_controls->setIsPreviousEnabled(
|
||||
mediaPlayer->previousAvailable(type));
|
||||
@ -75,8 +84,8 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||
});
|
||||
|
||||
auto unlocked = Core::App().passcodeLockChanges(
|
||||
) | rpl::filter([](bool locked) {
|
||||
return !locked;
|
||||
) | rpl::filter([=](bool locked) {
|
||||
return !locked && (mediaPlayer->current(type));
|
||||
}) | rpl::map([=] {
|
||||
return type;
|
||||
}) | rpl::before_next([=] {
|
||||
@ -145,4 +154,4 @@ SystemMediaControlsManager::SystemMediaControlsManager(HWND hwnd)
|
||||
|
||||
SystemMediaControlsManager::~SystemMediaControlsManager() = default;
|
||||
|
||||
} // namespace Platform
|
||||
} // namespace Window
|
@ -8,22 +8,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#pragma once
|
||||
|
||||
namespace base::Platform {
|
||||
class SystemMediaControlsWin;
|
||||
class SystemMediaControls;
|
||||
} // namespace base::Platform
|
||||
|
||||
namespace Data {
|
||||
class DocumentMedia;
|
||||
} // namespace Data
|
||||
|
||||
namespace Platform {
|
||||
namespace Window {
|
||||
|
||||
class SystemMediaControlsManager {
|
||||
public:
|
||||
SystemMediaControlsManager(HWND hwnd);
|
||||
SystemMediaControlsManager(not_null<QWidget*> parent);
|
||||
~SystemMediaControlsManager();
|
||||
|
||||
static bool Supported();
|
||||
|
||||
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;
|
||||
|
||||
@ -31,4 +33,4 @@ private:
|
||||
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…
Reference in New Issue
Block a user