Skip to content

Commit

Permalink
Changed IslandWindow from IConsoleWindow --> IUiaWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Jul 24, 2019
1 parent 867412a commit a815b42
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 165 deletions.
53 changes: 16 additions & 37 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#include "pch.h"
#include "BaseWindow.h"
#include "../types/IConsoleWindow.hpp"
#include "../types/IUiaWindow.h"
#include "WindowUiaProvider.hpp"
#include <winrt/Microsoft.Terminal.TerminalControl.h>
#include <winrt/TerminalApp.h>

class IslandWindow :
public BaseWindow<IslandWindow>,
public IConsoleWindow
public IUiaWindow
{
public:
IslandWindow() noexcept;
Expand All @@ -33,50 +33,29 @@ class IslandWindow :
void SetCreateCallback(std::function<void(const HWND, const RECT)> pfn) noexcept;

void UpdateTheme(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme);
#pragma region IConsoleWindow

BOOL EnableBothScrollBars() override
#pragma region IUiaWindow
void ChangeViewport(const SMALL_RECT NewWindow)
{
return false;
// TODO GitHub #1352: Hook up ScreenInfoUiaProvider to WindowUiaProvider
// Relevant comment from zadjii-msft:
/*
In my head for designing this, I'd then have IslandWindow::ChangeViewport
call a callback that AppHost sets, where AppHost will then call into the
TerminalApp to have TerminalApp handle the ChangeViewport call.
(See IslandWindow::SetCreateCallback as an example of a similar
pattern we're using today.) That way, if someone else were trying
to resuse this, they could have their own AppHost (or TerminalApp
equivalent) handle the ChangeViewport call their own way.
*/
return;
};
int UpdateScrollBar(_In_ bool isVertical,
_In_ bool isAltBuffer,
_In_ UINT pageSize,
_In_ int maxSize,
_In_ int viewportPosition) override { return -1; };

bool IsInFullscreen() const override { return false; };
void SetIsFullscreen(const bool fFullscreenEnabled) override{};
void ChangeViewport(const SMALL_RECT NewWindow) override{};

void CaptureMouse() override{};
BOOL ReleaseMouse() override { return false; };

HWND GetWindowHandle() const noexcept override
{
return BaseWindow::GetHandle();
};

void SetOwner() override{};

BOOL GetCursorPosition(_Out_ LPPOINT lpPoint) override { return false; };
BOOL GetClientRectangle(_Out_ LPRECT lpRect) override { return false; };
int MapPoints(_Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints) override { return -1; };
BOOL ConvertScreenToClient(_Inout_ LPPOINT lpPoint) override { return false; };

BOOL SendNotifyBeep() const override { return false; };

BOOL PostUpdateScrollBars() const override { return false; };

BOOL PostUpdateWindowSize() const override { return false; };

void UpdateWindowSize(const COORD coordSizeInChars) override{};
void UpdateWindowText() override{};

void HorizontalScroll(const WORD wScrollCommand,
const WORD wAbsoluteChange) override{};
void VerticalScroll(const WORD wScrollCommand,
const WORD wAbsoluteChange) override{};
[[nodiscard]] HRESULT SignalUia(_In_ EVENTID id) override { return E_NOTIMPL; };
[[nodiscard]] HRESULT UiaSetTextAreaFocus() override { return E_NOTIMPL; };

Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/WindowsTerminal/WindowUiaProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "../host/renderData.hpp"

WindowUiaProvider::WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow) :
WindowUiaProvider::WindowUiaProvider(Microsoft::Console::Types::IUiaWindow* baseWindow) :
//_pScreenInfoProvider{ nullptr },
WindowUiaProviderBase(baseWindow)
{
Expand All @@ -21,7 +21,7 @@ WindowUiaProvider::~WindowUiaProvider()
}*/
}

WindowUiaProvider* WindowUiaProvider::Create(Microsoft::Console::Types::IConsoleWindow* baseWindow)
WindowUiaProvider* WindowUiaProvider::Create(Microsoft::Console::Types::IUiaWindow* baseWindow)
{
WindowUiaProvider* pWindowProvider = nullptr;
Microsoft::Console::Types::ScreenInfoUiaProvider* pScreenInfoProvider = nullptr;
Expand Down
5 changes: 3 additions & 2 deletions src/cascadia/WindowsTerminal/WindowUiaProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Author(s):
#pragma once

#include "../types/WindowUiaProviderBase.hpp"
#include "../types/IUiaWindow.h"

class WindowUiaProvider final :
public Microsoft::Console::Types::WindowUiaProviderBase
{
public:
static WindowUiaProvider* Create(Microsoft::Console::Types::IConsoleWindow* baseWindow);
static WindowUiaProvider* Create(Microsoft::Console::Types::IUiaWindow* baseWindow);

[[nodiscard]] HRESULT Signal(_In_ EVENTID id) override;
[[nodiscard]] HRESULT SetTextAreaFocus() override;
Expand All @@ -47,6 +48,6 @@ class WindowUiaProvider final :
const OLECHAR* ProviderDescriptionPropertyName = L"Microsoft Windows Terminal Window";

private:
WindowUiaProvider(Microsoft::Console::Types::IConsoleWindow* baseWindow);
WindowUiaProvider(Microsoft::Console::Types::IUiaWindow* baseWindow);
~WindowUiaProvider();
};
11 changes: 3 additions & 8 deletions src/types/IConsoleWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ Author(s):

#pragma once

#include "IUiaWindow.h"

// copied typedef from uiautomationcore.h
typedef int EVENTID;

namespace Microsoft::Console::Types
{
class IConsoleWindow
class IConsoleWindow : public IUiaWindow
{
public:
virtual ~IConsoleWindow() = 0;
Expand All @@ -36,13 +38,9 @@ namespace Microsoft::Console::Types

virtual void SetIsFullscreen(const bool fFullscreenEnabled) = 0;

virtual void ChangeViewport(const SMALL_RECT NewWindow) = 0;

virtual void CaptureMouse() = 0;
virtual BOOL ReleaseMouse() = 0;

virtual HWND GetWindowHandle() const = 0;

// Pass null.
virtual void SetOwner() = 0;

Expand All @@ -64,9 +62,6 @@ namespace Microsoft::Console::Types
const WORD wAbsoluteChange) = 0;
virtual void VerticalScroll(const WORD wScrollCommand,
const WORD wAbsoluteChange) = 0;
[[nodiscard]] virtual HRESULT SignalUia(_In_ EVENTID id) = 0;
[[nodiscard]] virtual HRESULT UiaSetTextAreaFocus() = 0;
virtual RECT GetWindowRect() const = 0;
};

inline IConsoleWindow::~IConsoleWindow() {}
Expand Down
31 changes: 31 additions & 0 deletions src/types/IUiaWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- IUiaWindow.hpp
Abstract:
- Defines the methods and properties of what makes a window generate a UIA Tree for accessibility
Author(s):
- Carlos Zamora (CaZamor) July 2019
--*/

#pragma once

// copied typedef from uiautomationcore.h
typedef int EVENTID;

namespace Microsoft::Console::Types
{
class IUiaWindow
{
public:
virtual void ChangeViewport(const SMALL_RECT NewWindow) = 0;
virtual HWND GetWindowHandle() const = 0;
[[nodiscard]] virtual HRESULT SignalUia(_In_ EVENTID id) = 0;
[[nodiscard]] virtual HRESULT UiaSetTextAreaFocus() = 0;
virtual RECT GetWindowRect() const = 0;
};
}
8 changes: 4 additions & 4 deletions src/types/WindowUiaProviderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "precomp.h"

#include "IConsoleWindow.hpp"
#include "IUiaWindow.h"
#include "WindowUiaProviderBase.hpp"
#include "ScreenInfoUiaProvider.h"

using namespace Microsoft::Console::Types;

WindowUiaProviderBase::WindowUiaProviderBase(IConsoleWindow* baseWindow) :
WindowUiaProviderBase::WindowUiaProviderBase(IUiaWindow* baseWindow) :
_signalEventFiring{},
_baseWindow{ baseWindow },
_cRefs(1)
Expand Down Expand Up @@ -176,7 +176,7 @@ IFACEMETHODIMP WindowUiaProviderBase::get_BoundingRectangle(_Out_ UiaRect* pRect
{
RETURN_IF_FAILED(_EnsureValidHwnd());

const IConsoleWindow* const pConsoleWindow = _baseWindow;
const IUiaWindow* const pConsoleWindow = _baseWindow;
RETURN_HR_IF_NULL((HRESULT)UIA_E_ELEMENTNOTAVAILABLE, pConsoleWindow);

RECT const rc = pConsoleWindow->GetWindowRect();
Expand Down Expand Up @@ -210,7 +210,7 @@ IFACEMETHODIMP WindowUiaProviderBase::get_FragmentRoot(_COM_Outptr_result_mayben

HWND WindowUiaProviderBase::GetWindowHandle() const
{
IConsoleWindow* const pConsoleWindow = _baseWindow;
IUiaWindow* const pConsoleWindow = _baseWindow;
THROW_HR_IF_NULL(E_POINTER, pConsoleWindow);

return pConsoleWindow->GetWindowHandle();
Expand Down
6 changes: 3 additions & 3 deletions src/types/WindowUiaProviderBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Author(s):

namespace Microsoft::Console::Types
{
class IConsoleWindow;
class IUiaWindow;
class ScreenInfoUiaProvider;

class WindowUiaProviderBase :
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace Microsoft::Console::Types
_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) = 0;
virtual IFACEMETHODIMP GetFocus(_COM_Outptr_result_maybenull_ IRawElementProviderFragment** ppProvider) = 0;

WindowUiaProviderBase(IConsoleWindow* baseWindow);
WindowUiaProviderBase(IUiaWindow* baseWindow);

RECT GetWindowRect() const;
HWND GetWindowHandle() const;
Expand Down Expand Up @@ -96,7 +96,7 @@ namespace Microsoft::Console::Types
// Ref counter for COM object
ULONG _cRefs;

IConsoleWindow* _baseWindow;
IUiaWindow* _baseWindow;
};

namespace WindowUiaProviderTracing
Expand Down
1 change: 1 addition & 0 deletions src/types/lib/types.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ClInclude Include="..\inc\UTF8OutPipeReader.hpp" />
<ClInclude Include="..\inc\Viewport.hpp" />
<ClInclude Include="..\inc\Utf16Parser.hpp" />
<ClInclude Include="..\IUiaWindow.h" />
<ClInclude Include="..\precomp.h" />
<ClInclude Include="..\ScreenInfoUiaProvider.h" />
<ClInclude Include="..\UiaTextRange.hpp" />
Expand Down
Loading

0 comments on commit a815b42

Please sign in to comment.