aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Fedchin <anightik@gmail.com>2018-02-20 11:13:29 +0300
committerAnton Fedchin <anightik@gmail.com>2018-02-20 11:13:29 +0300
commit95819a357be23e7886f1ffdba6755534dd373e98 (patch)
treeec8d05a45197a90a05ecb1ea6f47e5ad443c26b8
parent52a316bbd81c1c74a801ebdbe56f9d2f4fbecf24 (diff)
[win10] improve window sizing/moving handling
-rw-r--r--xbmc/windowing/win10/WinEventsWin10.cpp65
-rw-r--r--xbmc/windowing/win10/WinEventsWin10.h14
-rw-r--r--xbmc/windowing/win10/WinSystemWin10DX.cpp1
3 files changed, 77 insertions, 3 deletions
diff --git a/xbmc/windowing/win10/WinEventsWin10.cpp b/xbmc/windowing/win10/WinEventsWin10.cpp
index 2ca96d804c..51562ccd09 100644
--- a/xbmc/windowing/win10/WinEventsWin10.cpp
+++ b/xbmc/windowing/win10/WinEventsWin10.cpp
@@ -29,6 +29,7 @@
#include "messaging/ApplicationMessenger.h"
#include "platform/win10/input/RemoteControlXbox.h"
#include "rendering/dx/DeviceResources.h"
+#include "platform/win10/AsyncHelpers.h"
#include "rendering/dx/RenderContext.h"
#include "utils/log.h"
#include "utils/SystemInfo.h"
@@ -108,6 +109,21 @@ void CWinEventsWin10::InitEventHandlers(CoreWindow^ window)
window->SizeChanged += ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>([&](CoreWindow^ wnd, WindowSizeChangedEventArgs^ args) {
OnWindowSizeChanged(wnd, args);
});
+#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
+ try
+ {
+ window->ResizeStarted += ref new TypedEventHandler<CoreWindow^, Platform::Object^>([&](CoreWindow^ wnd, Platform::Object^ args) {
+ OnWindowResizeStarted(wnd, args);
+ });
+ window->ResizeCompleted += ref new TypedEventHandler<CoreWindow^, Platform::Object^>([&](CoreWindow^ wnd, Platform::Object^ args) {
+ OnWindowResizeCompleted(wnd, args);
+ });
+ }
+ catch (Platform::Exception^ ex)
+ {
+ // Win10 Creators Update is required
+ }
+#endif
window->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>([&](CoreWindow^ wnd, CoreWindowEventArgs^ args) {
OnWindowClosed(wnd, args);
});
@@ -191,8 +207,51 @@ void CWinEventsWin10::UpdateWindowSize()
// Window event handlers.
void CWinEventsWin10::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
{
- DX::Windowing().OnResize(args->Size.Width, args->Size.Height);
- UpdateWindowSize();
+ CLog::Log(LOGDEBUG, __FUNCTION__": window size changed.");
+ m_logicalWidth = args->Size.Width;
+ m_logicalHeight = args->Size.Height;
+ m_bResized = true;
+
+ if (m_sizeChanging)
+ return;
+
+ HandleWindowSizeChanged();
+}
+
+void CWinEventsWin10::OnWindowResizeStarted(Windows::UI::Core::CoreWindow^ sender, Platform::Object ^ args)
+{
+ CLog::Log(LOGDEBUG, __FUNCTION__": window resize started.");
+ m_logicalPosX = sender->Bounds.X;
+ m_logicalPosY = sender->Bounds.Y;
+ m_sizeChanging = true;
+}
+
+void CWinEventsWin10::OnWindowResizeCompleted(Windows::UI::Core::CoreWindow^ sender, Platform::Object ^ args)
+{
+ CLog::Log(LOGDEBUG, __FUNCTION__": window resize completed.");
+ m_sizeChanging = false;
+
+ if (m_logicalPosX != sender->Bounds.X || m_logicalPosY != sender->Bounds.Y)
+ m_bMoved = true;
+
+ HandleWindowSizeChanged();
+}
+
+void CWinEventsWin10::HandleWindowSizeChanged()
+{
+ CLog::Log(LOGDEBUG, __FUNCTION__": window size/move handled.");
+ if (m_bMoved)
+ {
+ // it will get position from CoreWindow
+ DX::Windowing().OnMove(0, 0);
+ }
+ if (m_bResized)
+ {
+ DX::Windowing().OnResize(m_logicalWidth, m_logicalHeight);
+ UpdateWindowSize();
+ }
+ m_bResized = false;
+ m_bMoved = false;
}
void CWinEventsWin10::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
@@ -487,7 +546,7 @@ void CWinEventsWin10::OnOrientationChanged(DisplayInformation^ sender, Platform:
void CWinEventsWin10::OnDisplayContentsInvalidated(DisplayInformation^ sender, Platform::Object^ args)
{
- //critical_section::scoped_lock lock(m_deviceResources->GetCriticalSection());
+ CLog::Log(LOGDEBUG, __FUNCTION__": onevent.");
DX::DeviceResources::Get()->ValidateDevice();
}
diff --git a/xbmc/windowing/win10/WinEventsWin10.h b/xbmc/windowing/win10/WinEventsWin10.h
index c7b1845869..98348ed5e3 100644
--- a/xbmc/windowing/win10/WinEventsWin10.h
+++ b/xbmc/windowing/win10/WinEventsWin10.h
@@ -26,6 +26,7 @@
#include "interfaces/IAnnouncer.h"
#include "windowing/WinEvents.h"
#include <concurrent_queue.h>
+#include <cmath>
class CWinEventsWin10 : public IWinEvents
, public ANNOUNCEMENT::IAnnouncer
@@ -41,6 +42,8 @@ public:
// Window event handlers.
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
+ void OnWindowResizeStarted(Windows::UI::Core::CoreWindow^ sender, Platform::Object^ args);
+ void OnWindowResizeCompleted(Windows::UI::Core::CoreWindow^ sender, Platform::Object^ args);
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
static void OnWindowActivationChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowActivatedEventArgs^ args);
static void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
@@ -65,10 +68,21 @@ public:
void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data) override;
private:
+ friend class CWinSystemWin10;
+
void UpdateWindowSize();
void Kodi_KeyEvent(unsigned int vkey, unsigned scancode, unsigned keycode, bool isDown);
+ void HandleWindowSizeChanged();
+
Concurrency::concurrent_queue<XBMC_Event> m_events;
Windows::Media::SystemMediaTransportControls^ m_smtc{ nullptr };
+ bool m_bResized{ false };
+ bool m_bMoved{ false };
+ bool m_sizeChanging{ false };
+ float m_logicalWidth{ 0 };
+ float m_logicalHeight{ 0 };
+ float m_logicalPosX{ 0 };
+ float m_logicalPosY{ 0 };
};
#endif // WINDOW_EVENTS_WIN10_H
diff --git a/xbmc/windowing/win10/WinSystemWin10DX.cpp b/xbmc/windowing/win10/WinSystemWin10DX.cpp
index 86100216b0..99714b5dce 100644
--- a/xbmc/windowing/win10/WinSystemWin10DX.cpp
+++ b/xbmc/windowing/win10/WinSystemWin10DX.cpp
@@ -122,6 +122,7 @@ bool CWinSystemWin10DX::ResizeWindow(int newWidth, int newHeight, int newLeft, i
void CWinSystemWin10DX::OnMove(int x, int y)
{
+ m_deviceResources->SetWindowPos(m_coreWindow->Bounds);
}
bool CWinSystemWin10DX::DPIChanged(WORD dpi, RECT windowRect) const